GUI: add create party
This commit is contained in:
parent
9a41329f2a
commit
7593985ceb
|
@ -49,4 +49,7 @@ Full;Plein;Full
|
|||
Close;Fermee;Close
|
||||
Owner;Proprietaire;Owner
|
||||
AnyMessage;Aucun message;Any message
|
||||
MustBeConnected;Doit etre connecte;Must be connected
|
||||
MustBeConnected;Doit etre connecte;Must be connected
|
||||
Create;Creer;Create
|
||||
Name;Nom;Name
|
||||
Size;Taille;Size
|
Can't render this file because it has a wrong number of fields in line 39.
|
|
@ -52,6 +52,7 @@
|
|||
<Compile Include="States\ConnectState.cs" />
|
||||
<Compile Include="States\GameState.cs" />
|
||||
<Compile Include="States\IndentificationState.cs" />
|
||||
<Compile Include="States\PartyCreateState.cs" />
|
||||
<Compile Include="States\PartyState.cs" />
|
||||
<Compile Include="States\MainMenuState.cs" />
|
||||
<Compile Include="States\OptionsState.cs" />
|
||||
|
|
|
@ -92,7 +92,6 @@ namespace Galactic_Colors_Control_GUI.States
|
|||
|
||||
private void OnEvent(object sender, EventArgs e)
|
||||
{
|
||||
//TODO add PartyKick
|
||||
EventData eve = ((EventDataArgs)e).Data;
|
||||
if (eve.type == EventTypes.ServerKick)
|
||||
{
|
||||
|
@ -110,66 +109,5 @@ namespace Galactic_Colors_Control_GUI.States
|
|||
{
|
||||
chatText += (text + Environment.NewLine);
|
||||
}
|
||||
|
||||
/*
|
||||
private void PartyClick()
|
||||
{
|
||||
showLoading = true;
|
||||
GUI.ResetFocus();
|
||||
//TODO
|
||||
/*
|
||||
if (showParty)
|
||||
{
|
||||
client.SendRequest("/party leave");
|
||||
showParty = false;
|
||||
showLoading = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
client.Output.Clear();
|
||||
client.SendRequest("/party list");
|
||||
int wait = 0;
|
||||
while (wait < 20)
|
||||
{
|
||||
if (client.Output.Count > 0)
|
||||
{
|
||||
wait = 20;
|
||||
}
|
||||
else
|
||||
{
|
||||
wait++;
|
||||
Thread.Sleep(200);
|
||||
}
|
||||
}
|
||||
if (client.Output.Count > 0)
|
||||
{
|
||||
Thread.Sleep(500);
|
||||
if (client.Output.Count > 1)
|
||||
{
|
||||
messageTitle = "Party";
|
||||
messageText = string.Empty;
|
||||
foreach (string line in client.Output.ToArray()) { messageText += (line + Environment.NewLine); }
|
||||
showOKMessage = true;
|
||||
client.Output.Clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
messageTitle = "Any party";
|
||||
messageText = string.Empty;
|
||||
foreach (string line in client.Output.ToArray()) { messageText += (line + Environment.NewLine); }
|
||||
showOKMessage = true;
|
||||
client.Output.Clear();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
messageTitle = "Timeout";
|
||||
messageText = "";
|
||||
showOKMessage = true;
|
||||
showLoading = false;
|
||||
client.Output.Clear();
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
|
@ -0,0 +1,103 @@
|
|||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System;
|
||||
using MyMonoGame.GUI;
|
||||
using Galactic_Colors_Control_Common.Protocol;
|
||||
using Galactic_Colors_Control_Common;
|
||||
|
||||
namespace Galactic_Colors_Control_GUI.States
|
||||
{
|
||||
public class PartyCreateState : State
|
||||
{
|
||||
private Message message;
|
||||
|
||||
private bool locked = false;
|
||||
private bool showLoading = false;
|
||||
private bool showOKMessage = false;
|
||||
private string name;
|
||||
private string size;
|
||||
|
||||
public override void Draw(SpriteBatch spritebatch)
|
||||
{
|
||||
Game.singleton.background.Draw(spritebatch);
|
||||
Game.singleton.GUI.Label(new MyMonoGame.Vector(Game.singleton.ScreenWidth / 2, Game.singleton.ScreenHeight / 4), Game.singleton.multilang.Get("GCC", Game.singleton.config.lang), Game.singleton.fonts.title, new MyMonoGame.Colors(Color.White), Manager.textAlign.centerCenter);
|
||||
if (showLoading)
|
||||
{
|
||||
Game.singleton.GUI.Box(new Rectangle(Game.singleton.ScreenWidth / 2 - 150, Game.singleton.ScreenHeight / 4 + 50, 300, 50), Game.singleton.buttonsSprites[0]);
|
||||
Game.singleton.GUI.Label(new Rectangle(Game.singleton.ScreenWidth / 2 - 150, Game.singleton.ScreenHeight / 4 + 50, 300, 50), Game.singleton.multilang.Get("Loading", Game.singleton.config.lang), Game.singleton.fonts.basic);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (showOKMessage)
|
||||
{
|
||||
Game.singleton.GUI.Box(new Rectangle(Game.singleton.ScreenWidth / 2 - 150, Game.singleton.ScreenHeight / 4 + 50, 300, 150), Game.singleton.buttonsSprites[0]);
|
||||
Game.singleton.GUI.Label(new MyMonoGame.Vector(Game.singleton.ScreenWidth / 2, Game.singleton.ScreenHeight / 4 + 60), message.title, Game.singleton.fonts.basic, null, Manager.textAlign.bottomCenter);
|
||||
Game.singleton.GUI.Label(new MyMonoGame.Vector(Game.singleton.ScreenWidth / 2, Game.singleton.ScreenHeight / 4 + 100), message.text, Game.singleton.fonts.small, null, Manager.textAlign.bottomCenter);
|
||||
if (Game.singleton.GUI.Button(new Rectangle(Game.singleton.ScreenWidth / 2 - 140, Game.singleton.ScreenHeight / 4 + 150, 280, 40), Game.singleton.buttonsSprites[0], Game.singleton.multilang.Get("OK", Game.singleton.config.lang), Game.singleton.fonts.basic)) { Game.singleton.GUI.ResetFocus(); showOKMessage = false; }
|
||||
}
|
||||
else
|
||||
{
|
||||
Game.singleton.GUI.Box(new Rectangle(Game.singleton.ScreenWidth / 2 - 60, Game.singleton.ScreenHeight / 2 - 100, 120, 210), Game.singleton.buttonsSprites[0]);
|
||||
Game.singleton.GUI.TextField(new Rectangle(Game.singleton.ScreenWidth / 2 - 50, Game.singleton.ScreenHeight / 2 - 90, 100, 40), ref name, Game.singleton.fonts.basic, null, Manager.textAlign.centerCenter, Game.singleton.multilang.Get("Name", Game.singleton.config.lang));
|
||||
Game.singleton.GUI.TextField(new Rectangle(Game.singleton.ScreenWidth / 2 - 50, Game.singleton.ScreenHeight / 2 - 40, 100, 40), ref size, Game.singleton.fonts.basic, null, Manager.textAlign.centerCenter, Game.singleton.multilang.Get("Size", Game.singleton.config.lang));
|
||||
if (Game.singleton.GUI.Button(new Rectangle(Game.singleton.ScreenWidth / 2 - 50, Game.singleton.ScreenHeight / 2 + 10, 100, 40), Game.singleton.buttonsSprites[0], Game.singleton.multilang.Get("Create", Game.singleton.config.lang), Game.singleton.fonts.basic, new MyMonoGame.Colors(Color.LightGray, Color.White)))
|
||||
{
|
||||
if (!locked)
|
||||
{
|
||||
locked = true;
|
||||
new Thread(CreateParty).Start();
|
||||
}
|
||||
}
|
||||
|
||||
if (Game.singleton.GUI.Button(new Rectangle(Game.singleton.ScreenWidth / 2 - 50, Game.singleton.ScreenHeight / 2 + 60, 100, 40), Game.singleton.buttonsSprites[0], Game.singleton.multilang.Get("Back", Game.singleton.config.lang), Game.singleton.fonts.basic, new MyMonoGame.Colors(Color.LightGray, Color.White)))
|
||||
{
|
||||
if (!locked)
|
||||
{
|
||||
locked = true;
|
||||
Game.singleton.GUI.ResetFocus();
|
||||
Game.singleton.client.ExitHost();
|
||||
Game.singleton.gameState = new PartyState();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateParty()
|
||||
{
|
||||
showLoading = true;
|
||||
if(name != null)
|
||||
{
|
||||
int count;
|
||||
string party = name;
|
||||
name = null;
|
||||
if (int.TryParse(size, out count))
|
||||
{
|
||||
size = null;
|
||||
ResultData res = Game.singleton.client.Request(new string[4] { "party", "create", party, count.ToString() });
|
||||
if (res.type == ResultTypes.OK)
|
||||
{
|
||||
Game.singleton.logger.Write("Create party " + Common.ArrayToString(res.result), Logger.logType.info);
|
||||
Game.singleton.gameState = new GameState();
|
||||
}
|
||||
else
|
||||
{
|
||||
Game.singleton.logger.Write("Create error " + Common.ArrayToString(res.result), Logger.logType.error);
|
||||
message.title = Game.singleton.multilang.Get("Error", Game.singleton.config.lang);
|
||||
message.text = Common.ArrayToString(res.result);
|
||||
showOKMessage = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
locked = false;
|
||||
showLoading = false;
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
Game.singleton.background.Update();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -67,14 +67,23 @@ namespace Galactic_Colors_Control_GUI.States
|
|||
new Thread(UpdateParty).Start();
|
||||
}
|
||||
}
|
||||
Game.singleton.GUI.TextField(new Rectangle(Game.singleton.ScreenWidth / 2 + 40, Game.singleton.ScreenHeight / 2 - 290, 100, 40), ref password, Game.singleton.fonts.basic, null, Manager.textAlign.centerCenter, Game.singleton.multilang.Get("Password", Game.singleton.config.lang));
|
||||
if (Game.singleton.GUI.Button(new Rectangle(Game.singleton.ScreenWidth / 2 + 40, Game.singleton.ScreenHeight / 2 - 290, 100, 40), Game.singleton.buttonsSprites[0], Game.singleton.multilang.Get("Create", Game.singleton.config.lang), Game.singleton.fonts.basic, new MyMonoGame.Colors(Color.LightGray, Color.White)))
|
||||
{
|
||||
if (!locked)
|
||||
{
|
||||
locked = true;
|
||||
Game.singleton.gameState = new PartyCreateState();
|
||||
}
|
||||
}
|
||||
|
||||
//TODO Game.singleton.GUI.TextField(new Rectangle(Game.singleton.ScreenWidth / 2 + 40, Game.singleton.ScreenHeight / 2 - 290, 100, 40), ref password, Game.singleton.fonts.basic, null, Manager.textAlign.centerCenter, Game.singleton.multilang.Get("Password", Game.singleton.config.lang));
|
||||
if (parties.Count > 0) {
|
||||
if (parties.Count > 10) {
|
||||
//TODO page change
|
||||
}
|
||||
for (int i = (page - 1) * 10; i < page * 10 && i < parties.Count; i++)
|
||||
{
|
||||
if (Game.singleton.GUI.Button(new Rectangle(Game.singleton.ScreenWidth / 2 - 100, Game.singleton.ScreenHeight / 2 - 250 + i*50, 200, 40), Game.singleton.buttonsSprites[0], parties[i].text, Game.singleton.fonts.basic, new MyMonoGame.Colors(Color.LightGray, Color.White)))
|
||||
if (Game.singleton.GUI.Button(new Rectangle(Game.singleton.ScreenWidth / 2 - 100, Game.singleton.ScreenHeight / 2 - 240 + i*50, 200, 40), Game.singleton.buttonsSprites[0], parties[i].text, Game.singleton.fonts.basic, new MyMonoGame.Colors(Color.LightGray, Color.White)))
|
||||
{
|
||||
locked = true;
|
||||
id = parties[i].id;
|
||||
|
@ -86,7 +95,7 @@ namespace Galactic_Colors_Control_GUI.States
|
|||
{
|
||||
Game.singleton.GUI.Label(new MyMonoGame.Vector(Game.singleton.ScreenWidth / 2, Game.singleton.ScreenHeight / 2 - 240), Game.singleton.multilang.Get("AnyParty", Game.singleton.config.lang), Game.singleton.fonts.basic, null, Manager.textAlign.centerCenter);
|
||||
}
|
||||
if (Game.singleton.GUI.Button(new Rectangle(Game.singleton.ScreenWidth / 2 - 75, Game.singleton.ScreenHeight / 2 + 250, 150, 40), Game.singleton.buttonsSprites[0], Game.singleton.multilang.Get("Back", Game.singleton.config.lang), Game.singleton.fonts.basic, new MyMonoGame.Colors(Color.LightGray, Color.White)))
|
||||
if (Game.singleton.GUI.Button(new Rectangle(Game.singleton.ScreenWidth / 2 - 75, Game.singleton.ScreenHeight / 2 + 240, 150, 40), Game.singleton.buttonsSprites[0], Game.singleton.multilang.Get("Back", Game.singleton.config.lang), Game.singleton.fonts.basic, new MyMonoGame.Colors(Color.LightGray, Color.White)))
|
||||
{
|
||||
if (!locked)
|
||||
{
|
||||
|
@ -143,7 +152,7 @@ namespace Galactic_Colors_Control_GUI.States
|
|||
}
|
||||
else
|
||||
{
|
||||
Game.singleton.logger.Write("Join error " + res.result, Logger.logType.error);
|
||||
Game.singleton.logger.Write("Join error " + Common.ArrayToString(res.result), Logger.logType.error);
|
||||
message.title = Game.singleton.multilang.Get("Error", Game.singleton.config.lang);
|
||||
message.text = Common.ArrayToString(res.result);
|
||||
showOKMessage = true;
|
||||
|
@ -153,11 +162,6 @@ namespace Galactic_Colors_Control_GUI.States
|
|||
locked = false;
|
||||
}
|
||||
|
||||
private void PartyCreate()
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
Game.singleton.background.Update();
|
||||
|
|
|
@ -153,8 +153,12 @@ namespace Galactic_Colors_Control
|
|||
try { Send(new RequestData(GetRequestId(), new string[1] { "exit" })); } catch { }// Tell the server we are exiting
|
||||
_run = false; //Stopping Thread
|
||||
RecieveThread.Join(2000);
|
||||
ClientSocket.Shutdown(SocketShutdown.Both);
|
||||
ClientSocket.Close();
|
||||
try
|
||||
{
|
||||
ClientSocket.Shutdown(SocketShutdown.Both);
|
||||
ClientSocket.Close();
|
||||
}
|
||||
catch { }
|
||||
ResetHost();
|
||||
}
|
||||
|
||||
|
|
Reference in New Issue