Esempio n. 1
0
    public override void OnNewFrameDraw2d(Game game, float deltaTime)
    {
        if (game.guistate != GuiState.MapLoading)
        {
            return;
        }

        GamePlatform platform = game.platform;
        float        one      = 1;

        Width  = platform.GetCanvasWidth();
        Height = platform.GetCanvasHeight();
        DrawBackground(game);

        string connecting = game.language.Connecting();

        if (game.issingleplayer && (!platform.SinglePlayerServerLoaded()))
        {
            connecting = "Starting game...";
        }
        if (game.maploadingprogress.ProgressStatus != null)
        {
            connecting = game.maploadingprogress.ProgressStatus;
        }

        if (game.invalidVersionDrawMessage != null)
        {
            game.Draw2dText(game.invalidVersionDrawMessage, game.fontMapLoading, game.xcenter(game.TextSizeWidth(game.invalidVersionDrawMessage, game.fontMapLoading)), Height / 2 - 50, null, false);
            string connect = "Click to connect";
            game.Draw2dText(connect, game.fontMapLoading, game.xcenter(game.TextSizeWidth(connect, game.fontMapLoading)), Height / 2 + 50, null, false);
            return;
        }

        IntRef serverNameWidth  = new IntRef();
        IntRef serverNameHeight = new IntRef();

        platform.TextSize(game.ServerInfo.ServerName, game.fontMapLoading, serverNameWidth, serverNameHeight);
        game.Draw2dText(game.ServerInfo.ServerName, game.fontMapLoading, game.xcenter(serverNameWidth.value), Height / 2 - 150, null, false);

        if (game.ServerInfo.ServerMotd != null)
        {
            IntRef serverMotdWidth  = new IntRef();
            IntRef serverMotdHeight = new IntRef();
            platform.TextSize(game.ServerInfo.ServerMotd, game.fontMapLoading, serverMotdWidth, serverMotdHeight);
            game.Draw2dText(game.ServerInfo.ServerMotd, game.fontMapLoading, game.xcenter(serverMotdWidth.value), Height / 2 - 100, null, false);
        }

        IntRef connectingWidth  = new IntRef();
        IntRef connectingHeight = new IntRef();

        platform.TextSize(connecting, game.fontMapLoading, connectingWidth, connectingHeight);
        game.Draw2dText(connecting, game.fontMapLoading, game.xcenter(connectingWidth.value), Height / 2 - 50, null, false);

        string progress  = platform.StringFormat(game.language.ConnectingProgressPercent(), platform.IntToString(game.maploadingprogress.ProgressPercent));
        string progress1 = platform.StringFormat(game.language.ConnectingProgressKilobytes(), platform.IntToString(game.maploadingprogress.ProgressBytes / 1024));

        if (game.maploadingprogress.ProgressPercent > 0)
        {
            IntRef progressWidth  = new IntRef();
            IntRef progressHeight = new IntRef();
            platform.TextSize(progress, game.fontMapLoading, progressWidth, progressHeight);
            game.Draw2dText(progress, game.fontMapLoading, game.xcenter(progressWidth.value), Height / 2 - 20, null, false);

            IntRef progress1Width  = new IntRef();
            IntRef progress1Height = new IntRef();
            platform.TextSize(progress1, game.fontMapLoading, progress1Width, progress1Height);
            game.Draw2dText(progress1, game.fontMapLoading, game.xcenter(progress1Width.value), Height / 2 + 10, null, false);

            float progressratio = one * game.maploadingprogress.ProgressPercent / 100;
            int   sizex         = 400;
            int   sizey         = 40;
            game.Draw2dTexture(game.WhiteTexture(), game.xcenter(sizex), Height / 2 + 70, sizex, sizey, null, 0, Game.ColorFromArgb(255, 0, 0, 0), false);
            int   red    = Game.ColorFromArgb(255, 255, 0, 0);
            int   yellow = Game.ColorFromArgb(255, 255, 255, 0);
            int   green  = Game.ColorFromArgb(255, 0, 255, 0);
            int[] colors = new int[3];
            colors[0] = red;
            colors[1] = yellow;
            colors[2] = green;
            int c = InterpolationCi.InterpolateColor(platform, progressratio, colors, 3);
            game.Draw2dTexture(game.WhiteTexture(), game.xcenter(sizex), Height / 2 + 70, progressratio * sizex, sizey, null, 0, c, false);
        }
    }
Esempio n. 2
0
    public override void Render(float dt)
    {
        if (!loaded)
        {
            preferences_ip   = menu.p.GetPreferences().GetString("ConnectToIpIp", "127.0.0.1");
            preferences_port = menu.p.GetPreferences().GetString("ConnectToIpPort", "25565");
            textboxIp.text   = preferences_ip;
            textboxPort.text = preferences_port;
            loaded           = true;
        }

        if (textboxIp.text != preferences_ip ||
            textboxPort.text != preferences_port)
        {
            preferences_ip   = textboxIp.text;
            preferences_port = textboxPort.text;
            Preferences preferences = menu.p.GetPreferences();
            preferences.SetString("ConnectToIpIp", preferences_ip);
            preferences.SetString("ConnectToIpPort", preferences_port);
            menu.p.SetPreferences(preferences);
        }

        GamePlatform p     = menu.p;
        float        scale = menu.GetScale();

        menu.DrawBackground();


        float leftx = p.GetCanvasWidth() / 2 - 400 * scale;
        float y     = p.GetCanvasHeight() / 2 - 250 * scale;

        string loginResultText = null;

        if (errorText != null)
        {
            menu.DrawText(loginResultText, 14 * scale, leftx, y - 50 * scale, TextAlign.Left, TextBaseline.Top);
        }

        menu.DrawText(title, 14 * scale, leftx, y + 50 * scale, TextAlign.Left, TextBaseline.Top);

        textboxIp.x        = leftx;
        textboxIp.y        = y + 100 * scale;
        textboxIp.sizex    = 256 * scale;
        textboxIp.sizey    = 64 * scale;
        textboxIp.fontSize = 14 * scale;

        textboxPort.x        = leftx;
        textboxPort.y        = y + 200 * scale;
        textboxPort.sizex    = 256 * scale;
        textboxPort.sizey    = 64 * scale;
        textboxPort.fontSize = 14 * scale;

        buttonConnect.x        = leftx;
        buttonConnect.y        = y + 400 * scale;
        buttonConnect.sizex    = 256 * scale;
        buttonConnect.sizey    = 64 * scale;
        buttonConnect.fontSize = 14 * scale;

        back.x        = 40 * scale;
        back.y        = p.GetCanvasHeight() - 104 * scale;
        back.sizex    = 256 * scale;
        back.sizey    = 64 * scale;
        back.fontSize = 14 * scale;

        DrawWidgets();
    }
Esempio n. 3
0
    public override void Render(float dt)
    {
        if (!triedSavedLogin)
        {
            Preferences preferences = menu.p.GetPreferences();
            loginUsername.text = preferences.GetString("Username", "");
            loginPassword.text = "";
            string token = preferences.GetString("Password", "");

            loginResultData = new LoginData();
            if (serverHash != null && token != "")
            {
                menu.Login(loginUsername.text, loginPassword.text, serverHash, token, loginResult, loginResultData);
            }

            triedSavedLogin = true;
        }
        if (loginResultData != null
            && loginResultData.ServerCorrect
            && loginResultData.PasswordCorrect)
        {
            if (loginRememberMe.text == menu.lang.Get("MainMenu_ChoiceYes"))
            {
                Preferences preferences = menu.p.GetPreferences();
                preferences.SetString("Username", loginUsername.text);
                if (loginResultData.Token != null && loginResultData.Token != "")
                {
                    preferences.SetString("Password", loginResultData.Token);
                }
                menu.p.SetPreferences(preferences);
            }
            menu.ConnectToGame(loginResultData, loginUsername.text);
        }

        GamePlatform p = menu.p;
        float scale = menu.GetScale();

        menu.DrawBackground();

        float leftx = p.GetCanvasWidth() / 2 - 400 * scale;
        float y = p.GetCanvasHeight() / 2 - 250 * scale;

        string loginResultText = null;
        if (loginResult.value == LoginResult.Failed)
        {
            loginResultText = menu.lang.Get("MainMenu_LoginInvalid");
        }
        if (loginResult.value == LoginResult.Connecting)
        {
            loginResultText = menu.lang.Get("MainMenu_LoginConnecting");
        }
        if (loginResultText != null)
        {
            menu.DrawText(loginResultText, 14 * scale, leftx, y - 50 * scale, TextAlign.Left, TextBaseline.Top);
        }

        menu.DrawText(title, 14 * scale, leftx, y + 50 * scale, TextAlign.Left, TextBaseline.Top);

        loginUsername.x = leftx;
        loginUsername.y = y + 100 * scale;
        loginUsername.sizex = 256 * scale;
        loginUsername.sizey = 64 * scale;
        loginUsername.fontSize = 14 * scale;

        loginPassword.x = leftx;
        loginPassword.y = y + 200 * scale;
        loginPassword.sizex = 256 * scale;
        loginPassword.sizey = 64 * scale;
        loginPassword.fontSize = 14 * scale;

        loginRememberMe.x = leftx;
        loginRememberMe.y = y + 300 * scale;
        loginRememberMe.sizex = 256 * scale;
        loginRememberMe.sizey = 64 * scale;
        loginRememberMe.fontSize = 14 * scale;

        login.x = leftx;
        login.y = y + 400 * scale;
        login.sizex = 256 * scale;
        login.sizey = 64 * scale;
        login.fontSize = 14 * scale;

        float rightx = p.GetCanvasWidth() / 2 + 150 * scale;

        // menu.DrawText("Create account", 14 * scale, rightx, y + 50 * scale, TextAlign.Left, TextBaseline.Top);

        createAccountUsername.x = rightx;
        createAccountUsername.y = y + 100 * scale;
        createAccountUsername.sizex = 256 * scale;
        createAccountUsername.sizey = 64 * scale;
        createAccountUsername.fontSize = 14 * scale;

        createAccountPassword.x = rightx;
        createAccountPassword.y = y + 200 * scale;
        createAccountPassword.sizex = 256 * scale;
        createAccountPassword.sizey = 64 * scale;
        createAccountPassword.fontSize = 14 * scale;

        createAccountRememberMe.x = rightx;
        createAccountRememberMe.y = y + 300 * scale;
        createAccountRememberMe.sizex = 256 * scale;
        createAccountRememberMe.sizey = 64 * scale;
        createAccountRememberMe.fontSize = 14 * scale;

        createAccount.x = rightx;
        createAccount.y = y + 400 * scale;
        createAccount.sizex = 256 * scale;
        createAccount.sizey = 64 * scale;
        createAccount.fontSize = 14 * scale;

        createAccountUsername.visible = false;
        createAccountPassword.visible = false;
        createAccountRememberMe.visible = false;
        createAccount.visible = false;

        back.x = 40 * scale;
        back.y = p.GetCanvasHeight() - 104 * scale;
        back.sizex = 256 * scale;
        back.sizey = 64 * scale;
        back.fontSize = 14 * scale;

        DrawWidgets();
    }
Esempio n. 4
0
    public override void Render(float dt)
    {
        GamePlatform p = menu.p;

        float scale = menu.GetScale();

        menu.DrawBackground();
        menu.DrawText(title, menu.fontMenuHeading, p.GetCanvasWidth() / 2, 10, TextAlign.Center, TextBaseline.Top);

        float leftx = p.GetCanvasWidth() / 2 - 128 * scale;
        float y     = p.GetCanvasHeight() / 2 + 0 * scale;

        play.x     = leftx;
        play.y     = y + 100 * scale;
        play.sizex = 256 * scale;
        play.sizey = 64 * scale;

        newWorld.x     = leftx;
        newWorld.y     = y + 170 * scale;
        newWorld.sizex = 256 * scale;
        newWorld.sizey = 64 * scale;

        modify.x     = leftx;
        modify.y     = y + 240 * scale;
        modify.sizex = 256 * scale;
        modify.sizey = 64 * scale;

        back.x     = 40 * scale;
        back.y     = p.GetCanvasHeight() - 104 * scale;
        back.sizex = 256 * scale;
        back.sizey = 64 * scale;

        open.x     = leftx;
        open.y     = y + 0 * scale;
        open.sizex = 256 * scale;
        open.sizey = 64 * scale;

        if (savegames == null)
        {
            IntRef savegamesCount_ = new IntRef();
            savegames      = menu.GetSavegames(savegamesCount_);
            savegamesCount = savegamesCount_.value;
        }

        for (int i = 0; i < 10; i++)
        {
            worldButtons[i].visible = false;
        }
        for (int i = 0; i < savegamesCount; i++)
        {
            worldButtons[i].visible = true;
            worldButtons[i].text    = menu.p.FileName(savegames[i]);
            worldButtons[i].x       = leftx;
            worldButtons[i].y       = 100 + 100 * scale * i;
            worldButtons[i].sizex   = 256 * scale;
            worldButtons[i].sizey   = 64 * scale;
        }

        open.visible     = menu.p.SinglePlayerServerAvailable();
        play.visible     = false;
        newWorld.visible = false;
        modify.visible   = false;
        for (int i = 0; i < savegamesCount; i++)
        {
            worldButtons[i].visible = false;
        }

        DrawWidgets();

        if (!menu.p.SinglePlayerServerAvailable())
        {
            menu.DrawText("Singleplayer is only available on desktop (Windows, Linux, Mac) version of game.", fontDefault, menu.p.GetCanvasWidth() / 2, menu.p.GetCanvasHeight() / 2, TextAlign.Center, TextBaseline.Middle);
        }
    }