Ejemplo n.º 1
0
 public override void OnNewFrame(Game game, NewFrameEventArgs args)
 {
     if (game.guistate == GuiState.MapLoading)
     {
         return;
     }
     if (!started)
     {
         started = true;
         if (!game.issingleplayer)
         {
             skinserverResponse = new HttpResponseCi();
             game.platform.WebClientDownloadDataAsync("http://manicdigger.sourceforge.net/skinserver.txt", skinserverResponse);
         }
     }
     LoadPlayerTextures(game);
 }
 public override void OnNewFrame(Game game, NewFrameEventArgs args)
 {
     if (game.guistate == GuiState.MapLoading)
     {
         return;
     }
     if (!started)
     {
         started = true;
         if (!game.issingleplayer)
         {
             skinserverResponse = new HttpResponseCi();
             game.platform.WebClientDownloadDataAsync("http://manicdigger.sourceforge.net/skinserver.txt", skinserverResponse);
         }
     }
     LoadPlayerTextures(game);
 }
Ejemplo n.º 3
0
    public ScreenMultiplayer()
    {
        WidgetCount            = 64 + serverButtonsCount;
        widgets                = new MenuWidget[WidgetCount];
        back                   = new MenuWidget();
        back.text              = "Back";
        back.type              = WidgetType.Button;
        back.nextWidget        = 1;
        connect                = new MenuWidget();
        connect.text           = "Connect";
        connect.type           = WidgetType.Button;
        connect.nextWidget     = 3;
        connectToIp            = new MenuWidget();
        connectToIp.text       = "Connect to IP";
        connectToIp.type       = WidgetType.Button;
        connectToIp.nextWidget = 2;
        refresh                = new MenuWidget();
        refresh.text           = "Refresh";
        refresh.type           = WidgetType.Button;
        refresh.nextWidget     = 0;

        page                 = 0;
        pageUp               = new MenuWidget();
        pageUp.text          = "";
        pageUp.type          = WidgetType.Button;
        pageUp.buttonStyle   = ButtonStyle.Text;
        pageUp.visible       = false;
        pageDown             = new MenuWidget();
        pageDown.text        = "";
        pageDown.type        = WidgetType.Button;
        pageDown.buttonStyle = ButtonStyle.Text;
        pageDown.visible     = false;

        loggedInName             = new MenuWidget();
        loggedInName.text        = "";
        loggedInName.type        = WidgetType.Button;
        loggedInName.buttonStyle = ButtonStyle.Text;

        logout      = new MenuWidget();
        logout.text = "";
        logout.type = WidgetType.Button;
        //logout.image = "serverlist_entry_background.png";
        logout.buttonStyle = ButtonStyle.Button;

        title = "Multiplayer";

        fontServerHeading       = new FontCi();
        fontServerHeading.style = 1;
        fontServerHeading.size  = 14;
        fontServerDescription   = new FontCi();
        fontDefault             = new FontCi();
        fontDefault.size        = 14;

        widgets[0] = back;
        widgets[1] = connect;
        widgets[2] = refresh;
        widgets[3] = connectToIp;
        widgets[4] = pageUp;
        widgets[5] = pageDown;
        widgets[6] = loggedInName;
        widgets[7] = logout;

        serverListAddress = new HttpResponseCi();
        serverListCsv     = new HttpResponseCi();
        serversOnList     = new ServerOnList[serversOnListCount];
        thumbResponses    = new ThumbnailResponseCi[serversOnListCount];

        serverButtons = new MenuWidget[serverButtonsCount];
        for (int i = 0; i < serverButtonsCount; i++)
        {
            MenuWidget b = new MenuWidget();
            b                = new MenuWidget();
            b.text           = "Invalid";
            b.type           = WidgetType.Button;
            b.visible        = false;
            b.image          = "serverlist_entry_noimage.png";
            serverButtons[i] = b;
            widgets[8 + i]   = b;
        }
        loading = true;
    }
Ejemplo n.º 4
0
 public abstract void WebClientDownloadDataAsync(string url, HttpResponseCi response);
Ejemplo n.º 5
0
 public abstract void WebClientUploadDataAsync(string url, byte[] data, int dataLength, HttpResponseCi response);
Ejemplo n.º 6
0
 public abstract void WebClientUploadDataAsync(string url, byte[] data, int dataLength, HttpResponseCi response);
Ejemplo n.º 7
0
 public abstract void WebClientDownloadDataAsync(string url, HttpResponseCi response);
Ejemplo n.º 8
0
    public void Update(GamePlatform platform)
    {
        if (loginResult == null)
        {
            return;
        }

        if (loginUrlResponse == null && loginUrl == null)
        {
            loginUrlResponse = new HttpResponseCi();
            platform.WebClientDownloadDataAsync("http://manicdigger.sourceforge.net/login.php", loginUrlResponse);
        }
        if (loginUrlResponse != null && loginUrlResponse.done)
        {
            loginUrl = platform.StringFromUtf8ByteArray(loginUrlResponse.value, loginUrlResponse.valueLength);
            loginUrlResponse = null;
        }

        if (loginUrl != null)
        {
            if (shouldLogin)
            {
                shouldLogin = false;
                string requestString = platform.StringFormat4("username={0}&password={1}&server={2}&token={3}"
                    , LoginUser, LoginPassword, LoginPublicServerKey, LoginToken);
                IntRef byteArrayLength = new IntRef();
                byte[] byteArray = platform.StringToUtf8ByteArray(requestString, byteArrayLength);
                loginResponse = new HttpResponseCi();
                platform.WebClientUploadDataAsync(loginUrl, byteArray, byteArrayLength.value, loginResponse);
            }
            if (loginResponse != null && loginResponse.done)
            {
                string responseString = platform.StringFromUtf8ByteArray(loginResponse.value, loginResponse.valueLength);
                resultLoginData.PasswordCorrect = !(platform.StringContains(responseString, "Wrong username") || platform.StringContains(responseString, "Incorrect username"));
                resultLoginData.ServerCorrect = !platform.StringContains(responseString, "server");
                if (resultLoginData.PasswordCorrect)
                {
                    loginResult.value = LoginResult.Ok;
                }
                else
                {
                    loginResult.value = LoginResult.Failed;
                }
                IntRef linesCount = new IntRef();
                string[] lines = platform.ReadAllLines(responseString, linesCount);
                if (linesCount.value >= 3)
                {
                    resultLoginData.AuthCode = lines[0];
                    resultLoginData.ServerAddress = lines[1];
                    resultLoginData.Port = platform.IntParse(lines[2]);
                    resultLoginData.Token = lines[3];
                }
                loginResponse = null;
            }
        }
    }
Ejemplo n.º 9
0
    public ScreenMultiplayer()
    {
        WidgetCount = 64 + serverButtonsCount;
        widgets = new MenuWidget[WidgetCount];
        back = new MenuWidget();
        back.text = "Back";
        back.type = WidgetType.Button;
        back.nextWidget = 1;
        connect = new MenuWidget();
        connect.text = "Connect";
        connect.type = WidgetType.Button;
        connect.nextWidget = 3;
        connectToIp = new MenuWidget();
        connectToIp.text = "Connect to IP";
        connectToIp.type = WidgetType.Button;
        connectToIp.nextWidget = 2;
        refresh = new MenuWidget();
        refresh.text = "Refresh";
        refresh.type = WidgetType.Button;
        refresh.nextWidget = 0;

        page = 0;
        pageUp = new MenuWidget();
        pageUp.text = "";
        pageUp.type = WidgetType.Button;
        pageUp.buttonStyle = ButtonStyle.Text;
        pageUp.visible = false;
        pageDown = new MenuWidget();
        pageDown.text = "";
        pageDown.type = WidgetType.Button;
        pageDown.buttonStyle = ButtonStyle.Text;
        pageDown.visible = false;

        loggedInName = new MenuWidget();
        loggedInName.text = "";
        loggedInName.type = WidgetType.Button;
        loggedInName.buttonStyle = ButtonStyle.Text;

        logout = new MenuWidget();
        logout.text = "";
        logout.type = WidgetType.Button;
        //logout.image = "serverlist_entry_background.png";
        logout.buttonStyle = ButtonStyle.Button;

        title = "Multiplayer";

        widgets[0] = back;
        widgets[1] = connect;
        widgets[2] = refresh;
        widgets[3] = connectToIp;
        widgets[4] = pageUp;
        widgets[5] = pageDown;
        widgets[6] = loggedInName;
        widgets[7] = logout;

        serverListAddress = new HttpResponseCi();
        serverListCsv = new HttpResponseCi();
        serversOnList = new ServerOnList[serversOnListCount];
        thumbResponses = new ThumbnailResponseCi[serversOnListCount];

        serverButtons = new MenuWidget[serverButtonsCount];
        for (int i = 0; i < serverButtonsCount; i++)
        {
            MenuWidget b = new MenuWidget();
            b = new MenuWidget();
            b.text = "Invalid";
            b.type = WidgetType.Button;
            b.visible = false;
            b.image = "serverlist_entry_noimage.png";
            serverButtons[i] = b;
            widgets[8 + i] = b;
        }
        loading = true;
    }
Ejemplo n.º 10
0
 public override void WebClientUploadDataAsync(string url, byte[] data, int dataLength, HttpResponseCi response)
 {
     UploadData d = new UploadData();
     d.url = url;
     d.data = data;
     d.dataLength = dataLength;
     d.response = response;
     System.Threading.ThreadPool.QueueUserWorkItem(DoUploadData, d);
 }
Ejemplo n.º 11
0
 public override void WebClientDownloadDataAsync(string url, HttpResponseCi response)
 {
     DownloadDataArgs args = new DownloadDataArgs();
     args.url = url;
     args.response = response;
     ThreadPool.QueueUserWorkItem(DownloadData, args);
 }