Exemplo n.º 1
0
    void DrawScene(float dt)
    {
        p.GlViewport(0, 0, viewportWidth, viewportHeight);
        p.GlClearColorBufferAndDepthBuffer();
        p.GlDisableDepthTest();
        p.GlDisableCullFace();
        {
            //Mat4.Perspective(pMatrix, 45, one * viewportWidth / viewportHeight, one / 100, one * 1000);
            //Mat4.Identity_(mvMatrix);
            //Mat4.Translate(mvMatrix, mvMatrix, Vec3.FromValues(0, 0, z));
        }
        {
            Mat4.Identity_(pMatrix);
            Mat4.Ortho(pMatrix, 0, p.GetCanvasWidth(), p.GetCanvasHeight(), 0, 0, 10);
        }

        screen.Render(dt);
    }
Exemplo 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;

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

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

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

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

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

        DrawWidgets();
    }
Exemplo n.º 3
0
    public override void Render(float dt)
    {
        if (!loaded)
        {
            menu.p.WebClientDownloadDataAsync("http://manicdigger.sourceforge.net/serverlistcsv.php", serverListAddress);
            loaded = true;
        }
        if (serverListAddress.done)
        {
            serverListAddress.done = false;
            menu.p.WebClientDownloadDataAsync(serverListAddress.GetString(menu.p), serverListCsv);
        }
        if (serverListCsv.done)
        {
            loading            = false;
            serverListCsv.done = false;
            for (int i = 0; i < serversOnListCount; i++)
            {
                serversOnList[i]  = null;
                thumbResponses[i] = null;
            }
            IntRef   serversCount = new IntRef();
            string[] servers      = menu.p.StringSplit(serverListCsv.GetString(menu.p), "\n", serversCount);
            for (int i = 0; i < serversCount.value; i++)
            {
                IntRef   ssCount = new IntRef();
                string[] ss      = menu.p.StringSplit(servers[i], "\t", ssCount);
                if (ssCount.value < 10)
                {
                    continue;
                }
                ServerOnList s = new ServerOnList();
                s.hash           = ss[0];
                s.name           = menu.p.DecodeHTMLEntities(ss[1]);
                s.motd           = menu.p.DecodeHTMLEntities(ss[2]);
                s.port           = menu.p.IntParse(ss[3]);
                s.ip             = ss[4];
                s.version        = ss[5];
                s.users          = menu.p.IntParse(ss[6]);
                s.max            = menu.p.IntParse(ss[7]);
                s.gamemode       = ss[8];
                s.players        = ss[9];
                serversOnList[i] = s;
            }
        }

        GamePlatform p = menu.p;

        float scale = menu.GetScale();

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

        connect.x     = p.GetCanvasWidth() / 2 - 300 * scale;
        connect.y     = p.GetCanvasHeight() - 104 * scale;
        connect.sizex = 256 * scale;
        connect.sizey = 64 * scale;

        connectToIp.x     = p.GetCanvasWidth() / 2 - 0 * scale;
        connectToIp.y     = p.GetCanvasHeight() - 104 * scale;
        connectToIp.sizex = 256 * scale;
        connectToIp.sizey = 64 * scale;

        refresh.x     = p.GetCanvasWidth() / 2 + 350 * scale;
        refresh.y     = p.GetCanvasHeight() - 104 * scale;
        refresh.sizex = 256 * scale;
        refresh.sizey = 64 * scale;

        pageUp.x     = p.GetCanvasWidth() - 94 * scale;
        pageUp.y     = 100 * scale + (serversPerPage - 1) * 70 * scale;
        pageUp.sizex = 64 * scale;
        pageUp.sizey = 64 * scale;
        pageUp.image = "serverlist_nav_down.png";

        pageDown.x     = p.GetCanvasWidth() - 94 * scale;
        pageDown.y     = 100 * scale;
        pageDown.sizex = 64 * scale;
        pageDown.sizey = 64 * scale;
        pageDown.image = "serverlist_nav_up.png";

        loggedInName.x     = p.GetCanvasWidth() - 228 * scale;
        loggedInName.y     = 32 * scale;
        loggedInName.sizex = 128 * scale;
        loggedInName.sizey = 32 * scale;
        if (loggedInName.text == "")
        {
            if (p.GetPreferences().GetString("Password", "") != "")
            {
                loggedInName.text = p.GetPreferences().GetString("Username", "Invalid");
            }
        }
        logout.visible = loggedInName.text != "";

        logout.x     = p.GetCanvasWidth() - 228 * scale;
        logout.y     = 62 * scale;
        logout.sizex = 128 * scale;
        logout.sizey = 32 * scale;
        logout.text  = "Logout";

        menu.DrawBackground();
        menu.DrawText(title, menu.fontMenuHeading, p.GetCanvasWidth() / 2, 10, TextAlign.Center, TextBaseline.Top);
        menu.DrawText(p.IntToString(page + 1), fontDefault, p.GetCanvasWidth() - 68 * scale, p.GetCanvasHeight() / 2, TextAlign.Center, TextBaseline.Middle);

        if (loading)
        {
            menu.DrawText(menu.lang.Get("MainMenu_MultiplayerLoading"), fontDefault, 100 * scale, 50 * scale, TextAlign.Left, TextBaseline.Top);
        }

        UpdateThumbnails();
        for (int i = 0; i < serverButtonsCount; i++)
        {
            serverButtons[i].visible = false;
        }

        serversPerPage = menu.p.FloatToInt((menu.p.GetCanvasHeight() - (2 * 100 * scale)) / 70 * scale);
        if (serversPerPage <= 0)
        {
            // Do not let this get negative
            serversPerPage = 1;
        }
        for (int i = 0; i < serversPerPage; i++)
        {
            int index = i + (serversPerPage * page);
            if (index > serversOnListCount)
            {
                //Reset to first page
                page  = 0;
                index = i + (serversPerPage * page);
            }
            ServerOnList s = serversOnList[index];
            if (s == null)
            {
                continue;
            }
            string t = menu.p.StringFormat2("{1}", menu.p.IntToString(index), s.name);
            t = menu.p.StringFormat2("{0}\n{1}", t, s.motd);
            t = menu.p.StringFormat2("{0}\n{1}", t, s.gamemode);
            t = menu.p.StringFormat2("{0}\n{1}", t, menu.p.IntToString(s.users));
            t = menu.p.StringFormat2("{0}/{1}", t, menu.p.IntToString(s.max));
            t = menu.p.StringFormat2("{0}\n{1}", t, s.version);

            serverButtons[i].text        = t;
            serverButtons[i].x           = 100 * scale;
            serverButtons[i].y           = 100 * scale + i * 70 * scale;
            serverButtons[i].sizex       = p.GetCanvasWidth() - 200 * scale;
            serverButtons[i].sizey       = 64 * scale;
            serverButtons[i].visible     = true;
            serverButtons[i].buttonStyle = ButtonStyle.ServerEntry;
            if (s.thumbnailError)
            {
                //Server did not respond to ServerQuery. Maybe not reachable?
                serverButtons[i].description = "Server did not respond to query!";
            }
            else
            {
                serverButtons[i].description = null;
            }
            if (s.thumbnailFetched && !s.thumbnailError)
            {
                serverButtons[i].image = menu.p.StringFormat("serverlist_entry_{0}.png", s.hash);
            }
            else
            {
                serverButtons[i].image = "serverlist_entry_noimage.png";
            }
        }
        UpdateScrollButtons();
        DrawWidgets();
        DrawServerWidgets();
    }
Exemplo n.º 4
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, 14)), Height / 2 - 50, null, false);
            string connect = "Click to connect";
            game.Draw2dText(connect, game.fontMapLoading, game.xcenter(game.TextSizeWidth(connect, 14)), Height / 2 + 50, null, false);
            return;
        }

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

        platform.TextSize(game.ServerInfo.ServerName, 14, 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, 14, 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, 14, 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, 14, 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, 14, 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);
        }
    }
Exemplo n.º 5
0
    public override void Render(float dt)
    {
        GamePlatform p = menu.p;

        float scale = menu.GetScale();

        menu.DrawBackground();
        menu.DrawText(title, 20 * scale, 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;
        play.fontSize = 14 * scale;

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

        modify.x        = leftx;
        modify.y        = y + 240 * scale;
        modify.sizex    = 256 * scale;
        modify.sizey    = 64 * scale;
        modify.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;

        open.x        = leftx;
        open.y        = y + 0 * scale;
        open.sizex    = 256 * scale;
        open.sizey    = 64 * scale;
        open.fontSize = 14 * 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;
            worldButtons[i].fontSize = 14 * 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.", 16 * scale, menu.p.GetCanvasWidth() / 2, menu.p.GetCanvasHeight() / 2, TextAlign.Center, TextBaseline.Middle);
        }
    }
Exemplo n.º 6
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();
    }