GUIStyle improvements & some simple UI graphics, networking bugfixes, separate Random class, some StyleCop cleanup

This commit is contained in:
Regalis
2015-07-02 22:24:50 +03:00
parent b493ed2b39
commit d836a99515
119 changed files with 8842 additions and 1277 deletions
+20 -20
View File
@@ -46,28 +46,28 @@ namespace Subsurface
GUIpanel = new GUIFrame(new Rectangle(0, 0, 300, Game1.GraphicsHeight), Color.DarkGray * 0.8f);
GUIpanel.Padding = new Vector4(10.0f, 10.0f, 10.0f, 10.0f);
physicsButton = new GUIButton(new Rectangle(0, 50, 200, 25), "Physics", Color.White, GUIpanel);
physicsButton = new GUIButton(new Rectangle(0, 50, 200, 25), "Physics", Alignment.Left, GUI.style, GUIpanel);
physicsButton.OnClicked += TogglePhysics;
new GUITextBlock(new Rectangle(0, 80, 0, 25), "Limbs:", Color.Transparent, Color.Black, Alignment.Left, GUIpanel);
limbList = new GUIListBox(new Rectangle(0, 110, 0, 250), Color.White * 0.7f, GUIpanel);
new GUITextBlock(new Rectangle(0, 80, 0, 25), "Limbs:", Color.Transparent, Color.Black, Alignment.Left, null, GUIpanel);
limbList = new GUIListBox(new Rectangle(0, 110, 0, 250), Color.White * 0.7f, GUI.style, GUIpanel);
limbList.OnSelected = SelectLimb;
new GUITextBlock(new Rectangle(0, 360, 0, 25), "Joints:", Color.Transparent, Color.Black, Alignment.Left, GUIpanel);
jointList = new GUIListBox(new Rectangle(0, 390, 0, 250), Color.White * 0.7f, GUIpanel);
new GUITextBlock(new Rectangle(0, 360, 0, 25), "Joints:", Color.Transparent, Color.Black, Alignment.Left, null, GUIpanel);
jointList = new GUIListBox(new Rectangle(0, 390, 0, 250), Color.White * 0.7f, GUI.style, GUIpanel);
while (Character.characterList.Count > 1)
while (Character.CharacterList.Count > 1)
{
Character.characterList.First().Remove();
Character.CharacterList.First().Remove();
}
if (Character.characterList.Count == 1)
if (Character.CharacterList.Count == 1)
{
if (editingCharacter != Character.characterList[0]) UpdateLimbLists(Character.characterList[0]);
editingCharacter = Character.characterList[0];
if (editingCharacter != Character.CharacterList[0]) UpdateLimbLists(Character.CharacterList[0]);
editingCharacter = Character.CharacterList[0];
Vector2 camPos = editingCharacter.animController.limbs[0].body.Position;
Vector2 camPos = editingCharacter.AnimController.limbs[0].body.Position;
camPos = ConvertUnits.ToDisplayUnits(camPos);
camPos.Y = -camPos.Y;
cam.TargetPos = camPos;
@@ -84,7 +84,7 @@ namespace Subsurface
textures = new List<Texture2D>();
texturePaths = new List<string>();
foreach (Limb limb in editingCharacter.animController.limbs)
foreach (Limb limb in editingCharacter.AnimController.limbs)
{
if (texturePaths.Contains(limb.sprite.FilePath)) continue;
textures.Add(limb.sprite.Texture);
@@ -113,7 +113,7 @@ namespace Subsurface
Ragdoll.UpdateAll((float)Physics.step);
Game1.world.Step((float)Physics.step);
Game1.World.Step((float)Physics.step);
Physics.accumulator -= Physics.step;
}
@@ -173,7 +173,7 @@ namespace Subsurface
x = Game1.GraphicsWidth - textures[i].Width;
spriteBatch.Draw(textures[i], new Vector2(x, y), Color.White);
foreach (Limb limb in editingCharacter.animController.limbs)
foreach (Limb limb in editingCharacter.AnimController.limbs)
{
if (limb.sprite.FilePath != texturePaths[i]) continue;
Rectangle rect = limb.sprite.SourceRect;
@@ -220,21 +220,21 @@ namespace Subsurface
private void UpdateLimbLists(Character character)
{
limbList.ClearChildren();
foreach (Limb limb in character.animController.limbs)
foreach (Limb limb in character.AnimController.limbs)
{
GUITextBlock textBlock = new GUITextBlock(
new Rectangle(0,0,0,25),
limb.type.ToString(),
Color.Transparent,
Color.Black,
Alignment.Left,
Alignment.Left, null,
limbList);
textBlock.Padding = new Vector4(10.0f, 0.0f, 0.0f, 0.0f);
textBlock.UserData = limb;
}
jointList.ClearChildren();
foreach (RevoluteJoint joint in character.animController.limbJoints)
foreach (RevoluteJoint joint in character.AnimController.limbJoints)
{
Limb limb1 = (Limb)(joint.BodyA.UserData);
Limb limb2 = (Limb)(joint.BodyB.UserData);
@@ -244,7 +244,7 @@ namespace Subsurface
limb1.type.ToString() + " - " + limb2.type.ToString(),
Color.Transparent,
Color.Black,
Alignment.Left,
Alignment.Left, null,
jointList);
textBlock.Padding = new Vector4(10.0f, 0.0f, 0.0f, 0.0f);
textBlock.UserData = joint;
@@ -253,7 +253,7 @@ namespace Subsurface
private void DrawJoints(SpriteBatch spriteBatch, Limb limb, Vector2 limbBodyPos)
{
foreach (var joint in editingCharacter.animController.limbJoints)
foreach (var joint in editingCharacter.AnimController.limbJoints)
{
Vector2 jointPos = Vector2.Zero;
@@ -297,7 +297,7 @@ namespace Subsurface
editingLimb = (Limb)selection;
limbPanel = new GUIFrame(new Rectangle(300, 0, 500, 100), Color.Gray*0.8f);
limbPanel.Padding = new Vector4(10.0f,10.0f,10.0f,10.0f);
new GUITextBlock(new Rectangle(0, 0, 200, 25), editingLimb.type.ToString(), Color.Transparent, Color.Black, Alignment.Left, limbPanel);
new GUITextBlock(new Rectangle(0, 0, 200, 25), editingLimb.type.ToString(), Color.Transparent, Color.Black, Alignment.Left, null, limbPanel);
//spriteOrigin = new GUITextBlock(new Rectangle(0, 25, 200, 25), "Sprite origin: ", Color.White, Color.Black, Alignment.Left, limbPanel);
+11 -12
View File
@@ -37,28 +37,28 @@ namespace Subsurface
//constructionList.OnSelected = MapEntityPrefab.SelectPrefab;
//constructionList.CheckSelected = MapEntityPrefab.GetSelected;
GUIButton button = new GUIButton(new Rectangle(0, 50, 100, 20), "Items", GUI.style, Alignment.Left, GUIpanel);
GUIButton button = new GUIButton(new Rectangle(0, 50, 100, 20), "Items", Alignment.Left, GUI.style, GUIpanel);
button.UserData = 0;
button.OnClicked = SelectTab;
button = new GUIButton(new Rectangle(0, 80, 100, 20), "Structures", GUI.style, Alignment.Left, GUIpanel);
button = new GUIButton(new Rectangle(0, 80, 100, 20), "Structures", Alignment.Left, GUI.style, GUIpanel);
button.UserData = 1;
button.OnClicked = SelectTab;
button = new GUIButton(new Rectangle(0, 140, 100, 20), "Character mode", GUI.style, Alignment.Left, GUIpanel);
button = new GUIButton(new Rectangle(0, 140, 100, 20), "Character mode", Alignment.Left, GUI.style, GUIpanel);
button.OnClicked = ToggleCharacterMode;
GUItabs = new GUIComponent[2];
int width = 400, height = 400;
GUItabs[0] = new GUIFrame(new Rectangle(Game1.GraphicsWidth/2-width/2, Game1.GraphicsHeight/2-height/2, width, height), Color.DarkGray*0.8f);
GUItabs[0].Padding = new Vector4(10.0f, 10.0f, 10.0f, 10.0f);
GUIListBox itemList = new GUIListBox(new Rectangle(0, 0, 0, 0), Color.White * 0.7f, GUItabs[0]);
GUIListBox itemList = new GUIListBox(new Rectangle(0, 0, 0, 0), Color.White * 0.7f, GUI.style, GUItabs[0]);
itemList.OnSelected = SelectPrefab;
itemList.CheckSelected = MapEntityPrefab.GetSelected;
GUItabs[1] = new GUIFrame(new Rectangle(Game1.GraphicsWidth / 2 - width / 2, Game1.GraphicsHeight / 2 - height / 2, width, height), Color.DarkGray * 0.8f);
GUItabs[1].Padding = new Vector4(10.0f, 10.0f, 10.0f, 10.0f);
GUIListBox structureList = new GUIListBox(new Rectangle(0, 0, 0, 300), Color.White * 0.7f, GUItabs[1]);
GUIListBox structureList = new GUIListBox(new Rectangle(0, 0, 0, 300), Color.White * 0.7f, GUI.style, GUItabs[1]);
structureList.OnSelected = SelectPrefab;
structureList.CheckSelected = MapEntityPrefab.GetSelected;
@@ -67,7 +67,7 @@ namespace Subsurface
GUIListBox parent = ((ep as ItemPrefab) == null) ? structureList : itemList;
Color color = ((parent.CountChildren % 2) == 0) ? Color.White : Color.LightGray;
GUIFrame frame = new GUIFrame(new Rectangle(0, 0, 0, 50), Color.Transparent, parent);
GUIFrame frame = new GUIFrame(new Rectangle(0, 0, 0, 50), Color.Transparent, null, parent);
frame.UserData = ep;
frame.Padding = new Vector4(5.0f, 5.0f, 5.0f, 5.0f);
frame.Color = color;
@@ -78,9 +78,8 @@ namespace Subsurface
new Rectangle(40, 0, 0, 25),
ep.Name,
Color.Transparent, Color.Black,
Alignment.Left,
Alignment.Left,
frame);
Alignment.Left, Alignment.Left,
null, frame);
textBlock.Padding = new Vector4(5.0f, 0.0f, 5.0f, 0.0f);
if (ep.sprite != null)
@@ -110,7 +109,7 @@ namespace Subsurface
{
dummyCharacter.Remove();
dummyCharacter = null;
Game1.world.ProcessChanges();
Game1.World.ProcessChanges();
}
}
@@ -120,7 +119,7 @@ namespace Subsurface
dummyCharacter = new Character("Content/Characters/Human/human.xml", Vector2.Zero);
Character.Controlled = dummyCharacter;
Game1.world.ProcessChanges();
Game1.World.ProcessChanges();
}
private bool SelectTab(GUIButton button, object obj)
@@ -190,7 +189,7 @@ namespace Subsurface
if (dummyCharacter.SelectedConstruction==null)
{
Vector2 mouseSimPos = FarseerPhysics.ConvertUnits.ToSimUnits(cam.ScreenToWorld(PlayerInput.MousePosition));
foreach (Limb limb in dummyCharacter.animController.limbs)
foreach (Limb limb in dummyCharacter.AnimController.limbs)
{
limb.body.SetTransform(mouseSimPos, 0.0f);
}
+4 -2
View File
@@ -96,7 +96,9 @@ namespace Subsurface
if (Game1.GameSession != null && Game1.GameSession.Level != null) Game1.GameSession.Submarine.Update((float)Physics.step);
Game1.world.Step((float)Physics.step);
Game1.World.Step((float)Physics.step);
Level.AfterWorldStep();
Physics.accumulator -= Physics.step;
}
@@ -188,7 +190,7 @@ namespace Subsurface
Submarine.DrawBack(spriteBatch);
foreach (Character c in Character.characterList) c.Draw(spriteBatch);
foreach (Character c in Character.CharacterList) c.Draw(spriteBatch);
spriteBatch.End();
+40 -62
View File
@@ -33,32 +33,29 @@ namespace Subsurface
public LobbyScreen()
{
Rectangle panelRect = new Rectangle(
(int)GUI.style.largePadding.X,
(int)GUI.style.largePadding.Y,
(int)(Game1.GraphicsWidth * 0.3f) - (int)(GUI.style.largePadding.X * 1.5f),
Game1.GraphicsHeight - (int)(GUI.style.largePadding.Y * 2));
40, 40,
(int)(Game1.GraphicsWidth * 0.3f) - 60,
Game1.GraphicsHeight - 80);
leftPanel = new GUIFrame(panelRect, GUI.style.backGroundColor);
leftPanel.Padding = GUI.style.smallPadding;
leftPanel = new GUIFrame(panelRect, GUI.style);
//leftPanel.Padding = GUI.style.smallPadding;
new GUITextBlock(new Rectangle(0, 0, 200, 25),
"asdfdasfasdf", Color.Transparent, Color.White, Alignment.Left, leftPanel);
"asdfdasfasdf", Color.Transparent, Color.White, Alignment.Left, GUI.style, leftPanel);
GUITextBlock moneyText = new GUITextBlock(new Rectangle(0, 30, 200, 25),
"", Color.Transparent, Color.White, Alignment.Left, leftPanel);
"", Color.Transparent, Color.White, Alignment.Left, GUI.style, leftPanel);
moneyText.TextGetter = GetMoney;
GUIButton button = new GUIButton(new Rectangle(0, 60, 100, 30), "Map", GUI.style, Alignment.Left, leftPanel);
GUIButton button = new GUIButton(new Rectangle(0, 60, 100, 30), "Map", null, Alignment.Left, GUI.style, leftPanel);
button.UserData = PanelTab.Map;
button.OnClicked = SelectRightPanel;
button = new GUIButton(new Rectangle(0, 100, 100, 30), "Crew", GUI.style, Alignment.Left, leftPanel);
button = new GUIButton(new Rectangle(0, 100, 100, 30), "Crew", null, Alignment.Left, GUI.style, leftPanel);
button.UserData = PanelTab.Crew;
button.OnClicked = SelectRightPanel;
button = new GUIButton(new Rectangle(0, 140, 100, 30), "Hire", GUI.style, Alignment.Left, leftPanel);
button = new GUIButton(new Rectangle(0, 140, 100, 30), "Hire", null, Alignment.Left, GUI.style, leftPanel);
button.UserData = PanelTab.Hire;
button.OnClicked = SelectRightPanel;
@@ -66,37 +63,37 @@ namespace Subsurface
//---------------------------------------------------------------
panelRect = new Rectangle(
panelRect.X + panelRect.Width + (int)(GUI.style.largePadding.X),
(int)GUI.style.largePadding.Y,
Game1.GraphicsWidth - panelRect.Width - (int)(GUI.style.largePadding.X * 3.0f),
Game1.GraphicsHeight - (int)(GUI.style.largePadding.Y * 2));
panelRect.X + panelRect.Width + 40,
40,
Game1.GraphicsWidth - panelRect.Width - 120,
Game1.GraphicsHeight - 80);
rightPanel = new GUIFrame[3];
rightPanel[(int)PanelTab.Crew] = new GUIFrame(panelRect, GUI.style.backGroundColor);
rightPanel[(int)PanelTab.Crew].Padding = GUI.style.smallPadding;
rightPanel[(int)PanelTab.Crew] = new GUIFrame(panelRect, GUI.style);
//rightPanel[(int)PanelTab.Crew].Padding = GUI.style.smallPadding;
new GUITextBlock(new Rectangle(0, 0, 200, 25), "Crew:", Color.Transparent, Color.White, Alignment.Left, rightPanel[(int)PanelTab.Crew]);
new GUITextBlock(new Rectangle(0, 0, 200, 25), "Crew:", Color.Transparent, Color.White, Alignment.Left, GUI.style, rightPanel[(int)PanelTab.Crew]);
characterList = new GUIListBox(new Rectangle(0, 30, 300, 0), Color.White, rightPanel[(int)PanelTab.Crew]);
characterList = new GUIListBox(new Rectangle(0, 30, 300, 0), GUI.style, rightPanel[(int)PanelTab.Crew]);
characterList.OnSelected = SelectCharacter;
//---------------------------------------
rightPanel[(int)PanelTab.Map] = new GUIFrame(panelRect, GUI.style.backGroundColor);
rightPanel[(int)PanelTab.Map].Padding = GUI.style.smallPadding;
rightPanel[(int)PanelTab.Map] = new GUIFrame(panelRect, GUI.style);
//rightPanel[(int)PanelTab.Map].Padding = GUI.style.smallPadding;
startButton = new GUIButton(new Rectangle(0, 0, 100, 30), "Start", GUI.style,
Alignment.BottomRight, rightPanel[(int)PanelTab.Map]);
startButton = new GUIButton(new Rectangle(0, 0, 100, 30), "Start",
Alignment.BottomRight, GUI.style, rightPanel[(int)PanelTab.Map]);
startButton.OnClicked = StartShift;
startButton.Enabled = false;
//---------------------------------------
rightPanel[(int)PanelTab.Hire] = new GUIFrame(panelRect, GUI.style.backGroundColor);
rightPanel[(int)PanelTab.Hire].Padding = GUI.style.smallPadding;
rightPanel[(int)PanelTab.Hire] = new GUIFrame(panelRect, GUI.style);
//rightPanel[(int)PanelTab.Hire].Padding = GUI.style.smallPadding;
hireList = new GUIListBox(new Rectangle(0, 30, 300, 0), Color.White, Alignment.Left, rightPanel[(int)PanelTab.Hire]);
hireList = new GUIListBox(new Rectangle(0, 30, 300, 0), GUI.style, Alignment.Left, rightPanel[(int)PanelTab.Hire]);
hireList.OnSelected = HireCharacter;
}
@@ -117,7 +114,7 @@ namespace Subsurface
if (previewPlatform != null)
{
Game1.world.RemoveBody(previewPlatform);
Game1.World.RemoveBody(previewPlatform);
previewPlatform = null;
}
@@ -142,11 +139,11 @@ namespace Subsurface
previewCharacter = new Character(characterList.SelectedData as CharacterInfo, pos);
previewCharacter.animController.isStanding = true;
previewCharacter.AnimController.IsStanding = true;
if (previewPlatform == null)
{
Body platform = BodyFactory.CreateRectangle(Game1.world, 3.0f, 1.0f, 5.0f);
Body platform = BodyFactory.CreateRectangle(Game1.World, 3.0f, 1.0f, 5.0f);
platform.SetTransform(new Vector2(pos.X, pos.Y - 3.5f), 0.0f);
platform.IsStatic = true;
}
@@ -161,9 +158,9 @@ namespace Subsurface
for (int i = 0; i < 500; i++)
{
previewCharacter.animController.Update((float)Physics.step);
previewCharacter.animController.UpdateAnim((float)Physics.step);
Game1.world.Step((float)Physics.step);
previewCharacter.AnimController.Update((float)Physics.step);
previewCharacter.AnimController.UpdateAnim((float)Physics.step);
Game1.World.Step((float)Physics.step);
}
}
@@ -173,10 +170,10 @@ namespace Subsurface
if (locationPanel != null) rightPanel[(int)PanelTab.Map].RemoveChild(locationPanel);
locationPanel = new GUIFrame(new Rectangle(0, 0, rightPanel[(int)PanelTab.Map].Rect.Width / 2 - 40, 190), Color.Transparent, rightPanel[(int)PanelTab.Map]);
locationPanel = new GUIFrame(new Rectangle(0, 0, rightPanel[(int)PanelTab.Map].Rect.Width / 2 - 40, 190), Color.Transparent, null, rightPanel[(int)PanelTab.Map]);
locationPanel.UserData = "selectedlocation";
new GUITextBlock(new Rectangle(0,0,100,20), location.Name, Color.Transparent, Color.White, Alignment.TopLeft, locationPanel);
new GUITextBlock(new Rectangle(0,0,100,20), location.Name, Color.Transparent, Color.White, Alignment.TopLeft, null, locationPanel);
startButton.Enabled = true;
@@ -190,7 +187,7 @@ namespace Subsurface
{
GUITextBlock textBlock = new GUITextBlock(
new Rectangle(0, 0, 0, 25),
c.name, GUI.style,
c.Name, GUI.style,
Alignment.Left,
Alignment.Left,
characterList);
@@ -202,27 +199,21 @@ namespace Subsurface
foreach (CharacterInfo c in gameMode.hireManager.availableCharacters)
{
GUIFrame frame = new GUIFrame(
new Rectangle(0, 0, 0, 25),
Color.White,
Alignment.Left,
GUI.style,
hireList);
new Rectangle(0, 0, 0, 25), Color.White, Alignment.Left, null, hireList);
frame.UserData = c;
frame.Padding = new Vector4(10.0f, 0.0f, 10.0f, 0.0f);
GUITextBlock textBlock = new GUITextBlock(
new Rectangle(0, 0, 0, 25),
c.name,
c.Name,
Color.Transparent, Color.Black,
Alignment.Left,
frame);
Alignment.Left, null, frame);
textBlock = new GUITextBlock(
new Rectangle(0, 0, 0, 25),
c.salary.ToString(),
c.Salary.ToString(),
Color.Transparent, Color.Black,
Alignment.Right,
frame);
Alignment.Right, null, frame);
}
}
@@ -334,25 +325,12 @@ namespace Subsurface
return "Money: " + ((Game1.GameSession == null) ? "" : gameMode.crewManager.Money.ToString());
}
private string GetDay()
{
return "Day #" + ((Game1.GameSession == null) ? "" : gameMode.Day.ToString());
}
private float GetWeekProgress()
{
if (Game1.GameSession == null) return 0.0f;
return (float)((gameMode.Day - 1) % 7) / 7.0f;
}
private bool SelectCharacter(object selection)
{
CharacterInfo characterInfo = selection as CharacterInfo;
if (characterInfo == null) return false;
if (Character.Controlled != null && characterInfo == Character.Controlled.info) return false;
if (Character.Controlled != null && characterInfo == Character.Controlled.Info) return false;
CreatePreviewCharacter();
+31 -33
View File
@@ -31,38 +31,38 @@ namespace Subsurface
Game1.GraphicsHeight/ 2 - 250,
500, 500);
menuTabs[(int)Tabs.Main] = new GUIFrame(panelRect, GUI.style.backGroundColor);
menuTabs[(int)Tabs.Main].Padding = GUI.style.smallPadding;
menuTabs[(int)Tabs.Main] = new GUIFrame(panelRect, GUI.style);
//menuTabs[(int)Tabs.Main].Padding = GUI.style.smallPadding;
GUIButton button = new GUIButton(new Rectangle(0, 0, 0, 30), "New Game", GUI.style, Alignment.CenterX, menuTabs[(int)Tabs.Main]);
GUIButton button = new GUIButton(new Rectangle(0, 0, 0, 30), "New Game", Alignment.CenterX, GUI.style, menuTabs[(int)Tabs.Main]);
button.UserData = (int)Tabs.NewGame;
button.OnClicked = SelectTab;
//button.Enabled = false;
button = new GUIButton(new Rectangle(0, 60, 0, 30), "Load Game", GUI.style, Alignment.CenterX, menuTabs[(int)Tabs.Main]);
button = new GUIButton(new Rectangle(0, 60, 0, 30), "Load Game", Alignment.CenterX, GUI.style, menuTabs[(int)Tabs.Main]);
button.UserData = (int)Tabs.LoadGame;
button.OnClicked = SelectTab;
button = new GUIButton(new Rectangle(0, 120, 0, 30), "Join Server", GUI.style, Alignment.CenterX, menuTabs[(int)Tabs.Main]);
button = new GUIButton(new Rectangle(0, 120, 0, 30), "Join Server", Alignment.CenterX, GUI.style, menuTabs[(int)Tabs.Main]);
button.UserData = (int)Tabs.JoinServer;
button.OnClicked = SelectTab;
button = new GUIButton(new Rectangle(0, 180, 0, 30), "Host Server", GUI.style, Alignment.CenterX, menuTabs[(int)Tabs.Main]);
button = new GUIButton(new Rectangle(0, 180, 0, 30), "Host Server", Alignment.CenterX, GUI.style, menuTabs[(int)Tabs.Main]);
button.OnClicked = HostServerClicked;
//button.Enabled = false;
button = new GUIButton(new Rectangle(0, 240, 0, 30), "Quit", GUI.style, Alignment.CenterX, menuTabs[(int)Tabs.Main]);
button = new GUIButton(new Rectangle(0, 240, 0, 30), "Quit", Alignment.CenterX, GUI.style, menuTabs[(int)Tabs.Main]);
button.OnClicked = QuitClicked;
//----------------------------------------------------------------------
menuTabs[(int)Tabs.NewGame] = new GUIFrame(panelRect, GUI.style.backGroundColor);
menuTabs[(int)Tabs.NewGame].Padding = GUI.style.smallPadding;
menuTabs[(int)Tabs.NewGame] = new GUIFrame(panelRect, GUI.style);
//menuTabs[(int)Tabs.NewGame].Padding = GUI.style.smallPadding;
new GUITextBlock(new Rectangle(0, 0, 0, 30), "New Game", Color.Transparent, Color.Black, Alignment.CenterX, menuTabs[(int)Tabs.NewGame]);
new GUITextBlock(new Rectangle(0, 0, 0, 30), "New Game", null, null, Alignment.CenterX, GUI.style, menuTabs[(int)Tabs.NewGame]);
new GUITextBlock(new Rectangle(0, 30, 0, 30), "Selected map:", Color.Transparent, Color.Black, Alignment.Left, menuTabs[(int)Tabs.NewGame]);
mapList = new GUIListBox(new Rectangle(0, 60, 200, 400), Color.White, menuTabs[(int)Tabs.NewGame]);
new GUITextBlock(new Rectangle(0, 30, 0, 30), "Selected map:", null, null, Alignment.Left, GUI.style, menuTabs[(int)Tabs.NewGame]);
mapList = new GUIListBox(new Rectangle(0, 60, 200, 400), GUI.style, menuTabs[(int)Tabs.NewGame]);
foreach (Submarine map in Submarine.SavedSubmarines)
{
@@ -70,30 +70,28 @@ namespace Subsurface
new Rectangle(0, 0, 0, 25),
map.Name,
GUI.style,
Alignment.Left,
Alignment.Left,
mapList);
Alignment.Left, Alignment.Left, mapList);
textBlock.Padding = new Vector4(10.0f, 0.0f, 0.0f, 0.0f);
textBlock.UserData = map;
}
if (Submarine.SavedSubmarines.Count > 0) mapList.Select(Submarine.SavedSubmarines[0]);
button = new GUIButton(new Rectangle(0, 0, 100, 30), "Start", GUI.style, Alignment.Right | Alignment.Bottom, menuTabs[(int)Tabs.NewGame]);
button = new GUIButton(new Rectangle(0, 0, 100, 30), "Start",Alignment.Right | Alignment.Bottom, GUI.style, menuTabs[(int)Tabs.NewGame]);
button.OnClicked = StartGame;
//----------------------------------------------------------------------
menuTabs[(int)Tabs.LoadGame] = new GUIFrame(panelRect, GUI.style.backGroundColor);
menuTabs[(int)Tabs.LoadGame].Padding = GUI.style.smallPadding;
menuTabs[(int)Tabs.LoadGame] = new GUIFrame(panelRect, GUI.style);
//menuTabs[(int)Tabs.LoadGame].Padding = GUI.style.smallPadding;
new GUITextBlock(new Rectangle(0, 0, 0, 30), "Load Game", Color.Transparent, Color.Black, Alignment.CenterX, menuTabs[(int)Tabs.LoadGame]);
new GUITextBlock(new Rectangle(0, 0, 0, 30), "Load Game", Color.Transparent, Color.Black, Alignment.CenterX, null, menuTabs[(int)Tabs.LoadGame]);
string[] saveFiles = Directory.GetFiles(SaveUtil.SaveFolder, "*.save");
//new GUITextBlock(new Rectangle(0, 30, 0, 30), "Selected map:", Color.Transparent, Color.Black, Alignment.Left, menuTabs[(int)Tabs.NewGame]);
saveList = new GUIListBox(new Rectangle(0, 60, 200, 400), Color.White, menuTabs[(int)Tabs.LoadGame]);
saveList = new GUIListBox(new Rectangle(0, 60, 200, 400), Color.White, GUI.style, menuTabs[(int)Tabs.LoadGame]);
foreach (string saveFile in saveFiles)
{
@@ -108,23 +106,23 @@ namespace Subsurface
textBlock.UserData = saveFile;
}
button = new GUIButton(new Rectangle(0, 0, 100, 30), "Start", GUI.style, Alignment.Right | Alignment.Bottom, menuTabs[(int)Tabs.LoadGame]);
button = new GUIButton(new Rectangle(0, 0, 100, 30), "Start",Alignment.Right | Alignment.Bottom, GUI.style, menuTabs[(int)Tabs.LoadGame]);
button.OnClicked = LoadGame;
//----------------------------------------------------------------------
menuTabs[(int)Tabs.JoinServer] = new GUIFrame(panelRect, GUI.style.backGroundColor);
menuTabs[(int)Tabs.JoinServer].Padding = GUI.style.smallPadding;
menuTabs[(int)Tabs.JoinServer] = new GUIFrame(panelRect, GUI.style);
//menuTabs[(int)Tabs.JoinServer].Padding = GUI.style.smallPadding;
new GUITextBlock(new Rectangle(0, 0, 0, 30), "Join Server", Color.Transparent, Color.Black, Alignment.CenterX, menuTabs[(int)Tabs.JoinServer]);
new GUITextBlock(new Rectangle(0, 30, 0, 30), "Name:", Color.Transparent, Color.Black, Alignment.CenterX, menuTabs[(int)Tabs.JoinServer]);
nameBox = new GUITextBox(new Rectangle(0, 60, 200, 30), Color.White, Color.Black, Alignment.CenterX, Alignment.CenterX, menuTabs[(int)Tabs.JoinServer]);
new GUITextBlock(new Rectangle(0, 0, 0, 30), "Join Server", GUI.style, Alignment.CenterX, Alignment.CenterX, menuTabs[(int)Tabs.JoinServer]);
new GUITextBlock(new Rectangle(0, 100, 0, 30), "Server IP:", Color.Transparent, Color.Black, Alignment.CenterX, menuTabs[(int)Tabs.JoinServer]);
ipBox = new GUITextBox(new Rectangle(0, 130, 200, 30), Color.White, Color.Black, Alignment.CenterX, Alignment.CenterX, menuTabs[(int)Tabs.JoinServer]);
new GUITextBlock(new Rectangle(0, 30, 0, 30), "Name:", GUI.style, Alignment.CenterX, Alignment.CenterX, menuTabs[(int)Tabs.JoinServer]);
nameBox = new GUITextBox(new Rectangle(0, 60, 200, 30), Color.White, Color.Black, Alignment.CenterX, Alignment.CenterX, null, menuTabs[(int)Tabs.JoinServer]);
GUIButton joinButton = new GUIButton(new Rectangle(0, 0, 200, 30), "Join", Color.White, Alignment.Bottom | Alignment.CenterX, menuTabs[(int)Tabs.JoinServer]);
new GUITextBlock(new Rectangle(0, 100, 0, 30), "Server IP:", GUI.style, Alignment.CenterX, Alignment.CenterX, menuTabs[(int)Tabs.JoinServer]);
ipBox = new GUITextBox(new Rectangle(0, 130, 200, 30), Color.White, Color.Black, Alignment.CenterX, Alignment.CenterX, null, menuTabs[(int)Tabs.JoinServer]);
GUIButton joinButton = new GUIButton(new Rectangle(0, 0, 200, 30), "Join", Alignment.BottomCenter, GUI.style, menuTabs[(int)Tabs.JoinServer]);
joinButton.OnClicked = JoinServer;
@@ -140,7 +138,7 @@ namespace Subsurface
private bool HostServerClicked(GUIButton button, object obj)
{
Game1.NetLobbyScreen.isServer = true;
Game1.NetLobbyScreen.IsServer = true;
Game1.NetLobbyScreen.Select();
return true;
}
@@ -211,7 +209,7 @@ namespace Subsurface
if (string.IsNullOrEmpty(nameBox.Text)) return false;
if (string.IsNullOrEmpty(ipBox.Text)) return false;
Game1.Client = new GameClient(nameBox.Text);
Game1.NetworkMember = new GameClient(nameBox.Text);
if (Game1.Client.ConnectToServer(ipBox.Text))
{
Game1.NetLobbyScreen.Select();
@@ -219,7 +217,7 @@ namespace Subsurface
}
else
{
Game1.Client = null;
Game1.NetworkMember = null;
return false;
}
}
+135 -120
View File
@@ -12,27 +12,27 @@ namespace Subsurface
{
class NetLobbyScreen : Screen
{
GUIFrame menu;
GUIFrame infoFrame;
GUIListBox playerList;
private GUIFrame menu;
private GUIFrame infoFrame;
private GUIListBox playerList;
GUIListBox mapList, modeList, chatBox;
GUITextBox textBox;
private GUIListBox subList, modeList, chatBox;
private GUITextBox textBox;
GUIScrollBar durationBar;
private GUIScrollBar durationBar;
GUIFrame playerFrame;
private GUIFrame playerFrame;
float camAngle;
private float camAngle;
Body previewPlatform;
Hull previewHull;
public bool isServer;
private Body previewPlatform;
private Hull previewHull;
public bool IsServer;
public Submarine SelectedMap
{
get { return mapList.SelectedData as Submarine; }
get { return subList.SelectedData as Submarine; }
}
@@ -50,6 +50,12 @@ namespace Subsurface
}
}
public string LevelSeed
{
get;
private set;
}
public string DurationText()
{
return "Game duration: "+GameDuration+" min";
@@ -58,48 +64,42 @@ namespace Subsurface
public NetLobbyScreen()
{
Rectangle panelRect = new Rectangle(
(int)GUI.style.largePadding.X,
(int)GUI.style.largePadding.Y,
(int)(Game1.GraphicsWidth - GUI.style.largePadding.X * 2.0f),
(int)(Game1.GraphicsHeight - GUI.style.largePadding.Y * 2.0f));
40, 40, Game1.GraphicsWidth - 80, Game1.GraphicsHeight - 80);
menu = new GUIFrame(panelRect, Color.Transparent);
//menu.Padding = GUI.style.smallPadding;
//server info panel ------------------------------------------------------------
infoFrame = new GUIFrame(new Rectangle(0, 0, (int)(panelRect.Width * 0.6f), (int)(panelRect.Height * 0.6f)), GUI.style.backGroundColor, menu);
infoFrame.Padding = GUI.style.smallPadding;
infoFrame = new GUIFrame(new Rectangle(0, 0, (int)(panelRect.Width * 0.6f), (int)(panelRect.Height * 0.6f)), GUI.style, menu);
//infoFrame.Padding = GUI.style.smallPadding;
//chatbox ----------------------------------------------------------------------
GUIFrame chatFrame = new GUIFrame(
new Rectangle(0, (int)(panelRect.Height * 0.6f + GUI.style.smallPadding.W),
new Rectangle(0, (int)(panelRect.Height * 0.6f + 20),
(int)(panelRect.Width * 0.6f),
(int)(panelRect.Height * 0.4f - GUI.style.smallPadding.W)),
GUI.style.backGroundColor, menu);
chatFrame.Padding = GUI.style.smallPadding;
(int)(panelRect.Height * 0.4f - 20)),
GUI.style, menu);
chatBox = new GUIListBox(new Rectangle(0,0,0,chatFrame.Rect.Height-80), Color.White, chatFrame);
textBox = new GUITextBox(new Rectangle(0, 0, 0, 25), Color.White, Color.Black, Alignment.Bottom, Alignment.Left, chatFrame);
chatBox = new GUIListBox(new Rectangle(0,0,0,chatFrame.Rect.Height-80), Color.White, GUI.style, chatFrame);
textBox = new GUITextBox(new Rectangle(0, 0, 0, 25), Alignment.Bottom, GUI.style, chatFrame);
textBox.OnEnter = EnterChatMessage;
//player info panel ------------------------------------------------------------
playerFrame = new GUIFrame(
new Rectangle((int)(panelRect.Width * 0.6f + GUI.style.smallPadding.Z), 0,
(int)(panelRect.Width * 0.4f - GUI.style.smallPadding.Z), (int)(panelRect.Height * 0.6f)),
GUI.style.backGroundColor, menu);
playerFrame.Padding = GUI.style.smallPadding;
new Rectangle((int)(panelRect.Width * 0.6f + 20), 0,
(int)(panelRect.Width * 0.4f - 20), (int)(panelRect.Height * 0.6f)),
GUI.style, menu);
//player list ------------------------------------------------------------------
GUIFrame playerListFrame = new GUIFrame(
new Rectangle((int)(panelRect.Width * 0.6f + GUI.style.smallPadding.Z), (int)(panelRect.Height * 0.6f + GUI.style.smallPadding.W),
(int)(panelRect.Width * 0.4f - GUI.style.smallPadding.Z), (int)(panelRect.Height * 0.4f - GUI.style.smallPadding.W)),
GUI.style.backGroundColor, menu);
playerListFrame.Padding = GUI.style.smallPadding;
new Rectangle((int)(panelRect.Width * 0.6f + 20), (int)(panelRect.Height * 0.6f + 20),
(int)(panelRect.Width * 0.4f - 20), (int)(panelRect.Height * 0.4f - 20)),
GUI.style, menu);
playerList = new GUIListBox(new Rectangle(0,0,0,0), Color.White, playerListFrame);
playerList = new GUIListBox(new Rectangle(0,0,0,0), Color.White, null, playerListFrame);
}
public override void Deselect()
@@ -108,7 +108,7 @@ namespace Subsurface
if (previewPlatform!=null)
{
Game1.world.RemoveBody(previewPlatform);
Game1.World.RemoveBody(previewPlatform);
previewPlatform = null;
}
@@ -123,41 +123,39 @@ namespace Subsurface
{
infoFrame.ClearChildren();
if (isServer && Game1.Server == null) Game1.Server = new GameServer();
if (IsServer && Game1.Server == null) Game1.NetworkMember = new GameServer();
textBox.Select();
//int oldMapIndex = 0;
//if (mapList != null && mapList.SelectedData != null) oldMapIndex = mapList.SelectedIndex;
new GUITextBlock(new Rectangle(0, 30, 0, 30), "Selected map:", Color.Transparent, Color.Black, Alignment.Left, infoFrame);
mapList = new GUIListBox(new Rectangle(0, 60, 200, 200), Color.White, infoFrame);
mapList.OnSelected = SelectMap;
mapList.Enabled = (Game1.Server!=null);
new GUITextBlock(new Rectangle(0, 30, 0, 30), "Selected submarine:", null, null, Alignment.Left, null, infoFrame);
subList = new GUIListBox(new Rectangle(0, 60, 200, 200), Color.White, GUI.style, infoFrame);
subList.OnSelected = SelectMap;
subList.Enabled = (Game1.Server!=null);
if (Submarine.SavedSubmarines.Count>0)
if (Submarine.SavedSubmarines.Count > 0)
{
foreach (Submarine map in Submarine.SavedSubmarines)
foreach (Submarine sub in Submarine.SavedSubmarines)
{
GUITextBlock textBlock = new GUITextBlock(
new Rectangle(0, 0, 0, 25),
map.Name,
GUI.style,
Alignment.Left,
Alignment.Left,
mapList);
sub.Name, GUI.style,
Alignment.Left, Alignment.Left,
subList);
textBlock.Padding = new Vector4(10.0f, 0.0f, 0.0f, 0.0f);
textBlock.UserData = map;
textBlock.UserData = sub;
}
}
else
{
DebugConsole.ThrowError("No saved maps found!");
DebugConsole.ThrowError("No saved submarines found!");
return;
}
new GUITextBlock(new Rectangle(220, 30, 0, 30), "Selected game mode: ", Color.Transparent, Color.Black, Alignment.Left, infoFrame);
modeList = new GUIListBox(new Rectangle(220, 60, 200, 200), Color.White, infoFrame);
new GUITextBlock(new Rectangle(220, 30, 0, 30), "Selected game mode: ", null, null, Alignment.Left, GUI.style, infoFrame);
modeList = new GUIListBox(new Rectangle(220, 60, 200, 200), GUI.style, infoFrame);
modeList.Enabled = (Game1.Server != null);
//modeList.OnSelected = new GUIListBox.OnSelectedHandler(SelectEvent);
@@ -167,69 +165,75 @@ namespace Subsurface
GUITextBlock textBlock = new GUITextBlock(
new Rectangle(0, 0, 0, 25),
mode.Name,
GUI.style,
Alignment.Left,
Alignment.Left,
mode.Name, GUI.style,
Alignment.Left, Alignment.Left,
modeList);
textBlock.Padding = new Vector4(10.0f, 0.0f, 0.0f, 0.0f);
textBlock.UserData = mode;
}
GUITextBlock durationText = new GUITextBlock(new Rectangle((int)(modeList.Rect.X + modeList.Rect.Width + GUI.style.smallPadding.X), modeList.Rect.Y, 100, 20),
"Game duration: ", Color.Transparent, Color.Black, Alignment.Left, infoFrame);
GUITextBlock durationText = new GUITextBlock(new Rectangle((int)(modeList.Rect.Right + 20 - 100), 30, 100, 20),
"Game duration: ", GUI.style, Alignment.Left, Alignment.TopLeft, infoFrame);
durationText.TextGetter = DurationText;
durationBar = new GUIScrollBar(new Rectangle((int)(modeList.Rect.X + modeList.Rect.Width + GUI.style.smallPadding.X), modeList.Rect.Y + 30, 100, 20),
Color.Gold, 0.1f, Alignment.Left, infoFrame);
durationBar = new GUIScrollBar(new Rectangle((int)(modeList.Rect.Right + 20 - 100), 60, 180, 20),
GUI.style, 0.1f, infoFrame);
durationBar.BarSize = 0.1f;
durationBar.Enabled = (Game1.Server != null);
new GUITextBlock(new Rectangle((int)(modeList.Rect.Right + 20 - 80), 100, 100, 20),
"Level Seed: ", GUI.style, Alignment.Left, Alignment.TopLeft, infoFrame);
GUITextBox seedBox = new GUITextBox(new Rectangle((int)(modeList.Rect.Right + 20 - 80), 130, 180, 20),
Alignment.TopLeft, GUI.style, infoFrame);
seedBox.OnEnter = SelectSeed;
seedBox.Enabled = (Game1.Server != null);
if (isServer && Game1.Server!=null)
if (IsServer && Game1.Server!=null)
{
GUIButton startButton = new GUIButton(new Rectangle(0,0,200,30), "Start", Color.White, Alignment.Right | Alignment.Bottom, infoFrame);
GUIButton startButton = new GUIButton(new Rectangle(0, 0, 200, 30), "Start", GUI.style, infoFrame);
startButton.OnClicked = Game1.Server.StartGame;
//mapList.OnSelected = new GUIListBox.OnSelectedHandler(Game1.server.UpdateNetLobby);
modeList.OnSelected = Game1.Server.UpdateNetLobby;
durationBar.OnMoved = Game1.Server.UpdateNetLobby;
if (mapList.CountChildren > 0) mapList.Select(0);
if (subList.CountChildren > 0) subList.Select(0);
if (GameModePreset.list.Count > 0) modeList.Select(0);
}
else
{
int x = playerFrame.Rect.Width / 2;
GUITextBox playerName = new GUITextBox(new Rectangle(x, 0, 0, 20), Color.White, Color.Black,
Alignment.Left | Alignment.Top, Alignment.Left, playerFrame);
playerName.Text = Game1.Client.CharacterInfo.name;
GUITextBox playerName = new GUITextBox(new Rectangle(x, 0, 0, 20),
Alignment.TopLeft, GUI.style, playerFrame);
playerName.Text = Game1.Client.CharacterInfo.Name;
playerName.OnEnter += ChangeCharacterName;
new GUITextBlock(new Rectangle(x,40,200, 30), "Gender: ", Color.Transparent, Color.Black,
Alignment.Left | Alignment.Top, Alignment.Left, playerFrame);
Alignment.TopLeft, GUI.style, playerFrame);
GUIButton maleButton = new GUIButton(new Rectangle(x+70,50,70,20), "Male", GUI.style,
Alignment.Left | Alignment.Top, playerFrame);
GUIButton maleButton = new GUIButton(new Rectangle(x+70,50,70,20), "Male",
Alignment.TopLeft, GUI.style,playerFrame);
maleButton.UserData = Gender.Male;
maleButton.OnClicked += SwitchGender;
GUIButton femaleButton = new GUIButton(new Rectangle(x+150, 50, 70, 20), "Female", GUI.style,
Alignment.Left | Alignment.Top, playerFrame);
GUIButton femaleButton = new GUIButton(new Rectangle(x+150, 50, 70, 20), "Female",
Alignment.TopLeft, GUI.style, playerFrame);
femaleButton.UserData = Gender.Female;
femaleButton.OnClicked += SwitchGender;
new GUITextBlock(new Rectangle(0, 150, 200, 30), "Job preferences:", Color.Transparent, Color.Black, Alignment.Left, playerFrame);
new GUITextBlock(new Rectangle(0, 150, 200, 30), "Job preferences:", GUI.style, playerFrame);
GUIListBox jobList = new GUIListBox(new Rectangle(0,180,200,0), Color.White, playerFrame);
GUIListBox jobList = new GUIListBox(new Rectangle(0,180,200,0), GUI.style, playerFrame);
foreach (Job job in Job.jobList)
{
GUITextBlock jobText = new GUITextBlock(new Rectangle(0,0,0,20), job.Name, Color.Transparent, Color.Black, Alignment.Left, jobList);
GUIButton upButton = new GUIButton(new Rectangle(jobText.Rect.Width - 40, 0, 20, 20), "u", Color.White, jobText);
GUITextBlock jobText = new GUITextBlock(new Rectangle(0,0,0,20), job.Name, GUI.style, jobList);
GUIButton upButton = new GUIButton(new Rectangle(jobText.Rect.Width - 40, 0, 20, 20), "u", GUI.style, jobText);
upButton.UserData = -1;
upButton.OnClicked += ChangeJobPreference;
GUIButton downButton = new GUIButton(new Rectangle(jobText.Rect.Width - 20, 0, 20, 20), "d", Color.White, jobText);
GUIButton downButton = new GUIButton(new Rectangle(jobText.Rect.Width - 20, 0, 20, 20), "d", GUI.style, jobText);
downButton.UserData = 1;
downButton.OnClicked += ChangeJobPreference;
}
@@ -340,9 +344,9 @@ namespace Subsurface
GUITextBlock msg = new GUITextBlock(new Rectangle(0, 0, 0, 20),
message,
((chatBox.CountChildren % 2) == 0) ? Color.Transparent : Color.Black*0.1f, color,
Alignment.Left, null, true);
Alignment.Left, GUI.style, null, true);
msg.Padding = new Vector4(GUI.style.smallPadding.X, 0, 0, 0);
msg.Padding = new Vector4(20, 0, 0, 0);
chatBox.AddChild(msg);
}
@@ -357,15 +361,8 @@ namespace Subsurface
{
if (String.IsNullOrEmpty(message)) return false;
if (isServer)
{
Game1.Server.SendChatMessage("Server: " + message);
}
else
{
Game1.Client.SendChatMessage(Game1.Client.Name + ": " + message);
}
Game1.NetworkMember.SendChatMessage(Game1.NetworkMember.Name + ": " + message);
return true;
}
@@ -379,11 +376,11 @@ namespace Subsurface
Game1.Client.Character = character;
character.animController.isStanding = true;
character.AnimController.IsStanding = true;
if (previewPlatform==null)
{
Body platform = BodyFactory.CreateRectangle(Game1.world, 3.0f, 1.0f, 5.0f);
Body platform = BodyFactory.CreateRectangle(Game1.World, 3.0f, 1.0f, 5.0f);
platform.SetTransform(new Vector2(pos.X, pos.Y - 2.5f), 0.0f);
platform.IsStatic = true;
}
@@ -398,9 +395,9 @@ namespace Subsurface
for (int i = 0; i < 500; i++)
{
character.animController.Update((float)Physics.step);
character.animController.UpdateAnim((float)Physics.step);
Game1.world.Step((float)Physics.step);
character.AnimController.Update((float)Physics.step);
character.AnimController.UpdateAnim((float)Physics.step);
Game1.World.Step((float)Physics.step);
}
}
@@ -409,7 +406,7 @@ namespace Subsurface
try
{
Gender gender = (Gender)obj;
Game1.Client.CharacterInfo.gender = gender;
Game1.Client.CharacterInfo.Gender = gender;
Game1.Client.SendCharacterData();
CreatePreviewCharacter();
}
@@ -420,11 +417,25 @@ namespace Subsurface
return true;
}
private bool SelectSeed(GUITextBox textBox, string seed)
{
if (string.IsNullOrWhiteSpace(seed))
{
textBox.Text = LevelSeed;
}
else
{
LevelSeed = seed;
}
return true;
}
private bool ChangeCharacterName(GUITextBox textBox, string newName)
{
if (string.IsNullOrEmpty(newName)) return false;
Game1.Client.CharacterInfo.name = newName;
Game1.Client.CharacterInfo.Name = newName;
Game1.Client.Name = newName;
Game1.Client.SendCharacterData();
@@ -463,10 +474,37 @@ namespace Subsurface
}
}
public bool TrySelectMap(string mapName, string md5Hash)
{
Submarine map = Submarine.SavedSubmarines.Find(m => m.Name == mapName);
if (map == null)
{
DebugConsole.ThrowError("The map ''" + mapName + "'' has been selected by the server.");
DebugConsole.ThrowError("Matching map not found in your map folder.");
return false;
}
else
{
if (map.Hash.MD5Hash != md5Hash)
{
DebugConsole.ThrowError("Your version of the map file ''" + map.Name + "'' doesn't match the server's version!");
DebugConsole.ThrowError("Your file: " + map.Name + "(MD5 hash : " + map.Hash.MD5Hash + ")");
DebugConsole.ThrowError("Server's file: " + mapName + "(MD5 hash : " + md5Hash + ")");
return false;
}
else
{
subList.Select(map);
//map.Load();
return true;
}
}
}
public void WriteData(NetOutgoingMessage msg)
{
Submarine selectedMap = mapList.SelectedData as Submarine;
Submarine selectedMap = subList.SelectedData as Submarine;
if (selectedMap==null)
{
@@ -481,35 +519,10 @@ namespace Subsurface
msg.Write(modeList.SelectedIndex);
msg.Write(durationBar.BarScroll);
msg.Write(LevelSeed);
}
public bool TrySelectMap(string mapName, string md5Hash)
{
Submarine map = Submarine.SavedSubmarines.Find(m => m.Name == mapName);
if (map==null)
{
DebugConsole.ThrowError("The map ''" + mapName + "'' has been selected by the server.");
DebugConsole.ThrowError("Matching map not found in your map folder.");
return false;
}
else
{
if (map.Hash.MD5Hash!=md5Hash)
{
DebugConsole.ThrowError("Your version of the map file ''"+map.Name+"'' doesn't match the server's version!");
DebugConsole.ThrowError("Your file: "+map.Name+"(MD5 hash : "+map.Hash.MD5Hash+")");
DebugConsole.ThrowError("Server's file: " + mapName + "(MD5 hash : " + md5Hash + ")");
return false;
}
else
{
mapList.Select(map);
//map.Load();
return true;
}
}
}
public void ReadData(NetIncomingMessage msg)
{
@@ -523,6 +536,8 @@ namespace Subsurface
modeList.Select(msg.ReadInt32());
durationBar.BarScroll = msg.ReadFloat();
LevelSeed = msg.ReadString();
}
}
}