Package fm.ak.client

Source Code of fm.ak.client.Clear

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package fm.ak.client;

import fm.ak.otse.Otse;
import fm.ak.otse.font.Text;
import fm.ak.otse.twod.Component;
import fm.ak.otse.Renderable;
import fm.ak.otse.twod.ComponentRenderer;
import fm.ak.otse.twod.Shader;
import fm.ak.otse.twod.Sheet;

/**
* the Clear is the rather open menu screen
*
* @author Petrus
*/
public final class Clear {

    Component spread;
    Component guy;
   
    //Settings settings;
   
    private String message;
    public Text text;
    public Text text2;

    //Load(Stuff.NECESSITIES);
    //Load(Stuff.TILES);
    //go();

    /**
     * creates the Clear. Does not {@link #display() } it yet
     */
    public Clear() {
        //settings = new Settings(StaticFont.SegoeUILight14, 0, 0, 0);
        spread = new Component("spread", 0, 0, Main.width, Main.height);
        guy = new Component("guy", 0, 0, Main.width, Main.height);
       
        new Shader();
    }
   
    /**
     * shows the clear
     *
     * @see #hide()
     */
    public void display() {
        ComponentRenderer cr = Otse.getInstance().getComponentRenderer();
        synchronized (cr.queue) {
            cr.queue.add(spread);
            cr.queue.add(guy);
        }
    }
   
    /**
     * removes the Clear from the screen. Does not {@link #unload} it
     */
    public void hide() {
        ComponentRenderer cr = Otse.getInstance().getComponentRenderer();
        synchronized (cr.components) {
            spread.markDispose();
            guy.markDispose();
            text.markDispose();
        }
    }
   
    /**
     *
     * @param quote
     */
    public void message(String quote) {
        message = quote;
       
        float r = 73;
        float g = 83;
        float b = 92;
       
        ComponentRenderer cr = Otse.getInstance().getComponentRenderer();
       
        synchronized (cr.queue) {
           
            if ( text != null )
                text.markDispose();
           
            /*
             * the underlying Text is still referenced in Component#components
             */

            text = Text.create(
                    StaticFont.SegoeUILight14,
                    message,
                    Main.width / 2 - (StaticFont.SegoeUILight14.stringWidth(message, Text.NORMAL_SPACING, 0, false) / 2),
                    (Main.height / 2) - (StaticFont.SegoeUILight14.getMetrics().Height / 2),
                    Text.NORMAL_SPACING,
                    0,
                    Text.NORMAL_ANGLE,
                    Renderable.Fades.IN,
                    r, g, b, 1);
           
            text.setSheetSprite(Main.main.sheet1, "entirety");
           
            text.index = 4;
        }
    }

    /**
     * go figure moron
     */
    public void load() {

        Sheet sheet;

        sheet = new Sheet("img/spread.png");
        spread.setSheetSprite(sheet, "entirety");
        spread.position(0, 0, Main.width, Main.height);
        spread.repeat = false; // so it stretches
       
        // out of place perhaps
        //Main.gooey = new Sheet("img/gui.png");
        //Main.gooey.sprite("box", new Sprite(0, 0, 500, 300));

        sheet = new Sheet("img/guy.png");
        guy.setSheetSprite(sheet, "entirety");
        int x = Main.width / 2 + 100;
        int y = Main.height / 2 - 128;
        guy.position(x, y, guy.w(), guy.h());

        //String s = "ak alpha multiplayer";
        //Text buildInf = Text.create(StaticShader.SegoeUILight14, s, 300, 300, 0, 0, 0, Renderable.Fades.NONE, 0, 0, 0, 1);
    }
   
    /**
     * unloads the resources used by Clear
     */
    public void unload() {
        System.out.println("unloading the clear");
       
        ComponentRenderer cr = Otse.getInstance().getComponentRenderer();
       
        synchronized (cr.components) {
            text.markDispose();
            text = null;
            spread.markDispose();
            guy.markDispose();
        }
    }
}
TOP

Related Classes of fm.ak.client.Clear

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.