74f32d14d4
commit 2ad9b5de40f128e8413f1ad5f568a4bc006d0971 Author: Joonas Rikkonen <poe.regalis@gmail.com> Date: Wed Feb 6 20:11:41 2019 +0200 v0.8.9.3 commit 2d64da9d1e0d10f9ccb08d6e3fbc45d69fcda368 Author: itchyOwl <lauri.harkanen@gmail.com> Date: Wed Feb 6 18:08:10 2019 +0200 Randomize the races and the heads in the net lobby. TODO: remember the previous heads and check that the next in line is unique (not exactly the same as the current). commit 09f74ab37692291ca070bac5dbc53eef395fb1cf Author: Joonas Rikkonen <poe.regalis@gmail.com> Date: Wed Feb 6 16:30:16 2019 +0200 AI characters can give treatment to characters who aren't unconscious, fixed AI characters attempting to treat dead characters. Closes #1083 commit a8fea2450cf4ef0b80a8fc809aee339bc39b28c6 Author: Joonas Rikkonen <poe.regalis@gmail.com> Date: Wed Feb 6 16:28:23 2019 +0200 Fixed horizontal docking ports failing to find the hull prefab commit dd5a7a4f09195ecfeb82605e1e73ea22607694e7 Author: ezjamsen <ezjames.fi@gmail.com> Date: Wed Feb 6 16:02:52 2019 +0200 halved the hitpoints for baby moloch commit 92ae260558ece991560d83819168ef51d5267a66 Merge: 75fe087d7 8f451825e Author: itchyOwl <lauri.harkanen@gmail.com> Date: Wed Feb 6 15:44:08 2019 +0200 Merge branch 'dev' of https://github.com/Regalis11/Barotrauma into dev commit 75fe087d7263b46611fb0aad5c91c616e22ad41b Author: itchyOwl <lauri.harkanen@gmail.com> Date: Wed Feb 6 15:43:12 2019 +0200 Update the ai block in the moloch boss config file. commit caf11944294dfe66b5d302888baecbfddad7293a Author: itchyOwl <lauri.harkanen@gmail.com> Date: Wed Feb 6 15:42:42 2019 +0200 Remove the lowercase version of the moloch boss config file. commit b422feece1e620c427fa62d41c2b847b6b8837e9 Author: itchyOwl <lauri.harkanen@gmail.com> Date: Wed Feb 6 15:41:40 2019 +0200 Fix molochbaby character name in the config file. commit 913762516dd17921c185de2cb912333f2e5230dd Author: itchyOwl <lauri.harkanen@gmail.com> Date: Wed Feb 6 15:41:22 2019 +0200 Include the baby moloch files in the project. commit 8f451825e95b415b1262f984d83828c379d36ea2 Author: Joonas Rikkonen <poe.regalis@gmail.com> Date: Wed Feb 6 15:36:50 2019 +0200 Added molochbaby to the project file commit 2078307f255f432c19fcbbc0b690acf5655f3c99 Author: itchyOwl <lauri.harkanen@gmail.com> Date: Wed Feb 6 15:33:08 2019 +0200 Disable creating humanoids in the wizard for now, because it can go wrong in so many ways. commit 55a931795ac5f60699033c4ff484a9a2d0ae9b7e Author: itchyOwl <lauri.harkanen@gmail.com> Date: Wed Feb 6 15:32:18 2019 +0200 Unfreeze when adjusting the joint scale, because the limbs are not otherwise updated to the joint positions. commit 2c92373ccbf331c545c830c9780f450b116f0359 Author: Iiro Enges <iiro@fakefish.fi> Date: Wed Feb 6 15:28:22 2019 +0200 Tinted baby moloch to differentiate from the adult version (for testing purposes) commit f05be351cdf8a6073702e988ed1861f665399048 Author: Joonas Rikkonen <poe.regalis@gmail.com> Date: Wed Feb 6 15:26:52 2019 +0200 Fixed automatic temperature control setting turbine output above 100 if the power consumption is higher than what the reactor can generate. Caused "failed to write an event for the entity" errors in MP when the server tried to write the targetTurbineOutput using WriteRangedSingle with a maximum value of 100. Closes #1085 commit 7b737ebbea41fd5b7825a6c6373e578c1b1c91fd Author: ezjamsen <ezjames.fi@gmail.com> Date: Wed Feb 6 15:15:59 2019 +0200 Baby moloch, doo doo doo doo doo doo commit f5d13649915ba761bbc6fe78370c607905e2d5f8 Author: ezjamsen <ezjames.fi@gmail.com> Date: Wed Feb 6 15:15:04 2019 +0200 Small fixes and tweaks to gun performance dependent on skill of user. commit 4bf61738c6da08d771dedf1c96160cc76e0b4dd7 Author: ezjamsen <ezjames.fi@gmail.com> Date: Wed Feb 6 15:14:11 2019 +0200 New staggered swarm medium difficulty event commit 3e593f46850987ba074d9b26d59d08eeeddd1d70 Author: Joonas Rikkonen <poe.regalis@gmail.com> Date: Wed Feb 6 15:05:43 2019 +0200 Removed incorrect item name/description instructions fron EnglishVanilla.xml. Correct instructions are at the beginning of the file. commit ce33a523e440a5b5037b84ca96bebf1f977e0aa8 Author: Joonas Rikkonen <poe.regalis@gmail.com> Date: Wed Feb 6 15:00:48 2019 +0200 Attempt to fix "attempted to move pull joint extremely far" errors (#895). I think they were (at least for the most part) caused by characters switching to simple physics mode and then moving a significant distance, and when the character switched back to normal animation, the pull joints were still somewhere far away and lerping them to the position of the collider failed (because the lerped position triggers the error). commit c8212e3eff6d9272c9d38b833743b0f33b3611a2 Author: Joonas Rikkonen <poe.regalis@gmail.com> Date: Wed Feb 6 13:54:15 2019 +0200 Fixed nullref exception when teleporting from a sub to ruins or vice versa. Closes #1037 commit 0d812394944eb05be4291be7b56593cc4def6d0f Author: Daniel Asteljoki <daniel.asteljoki@gmail.com> Date: Wed Feb 6 13:34:58 2019 +0200 Made regular ruin walls much more durable (500 -> 5000) commit c9a4d9d6f6c9c767ecd8cf34f917db9da852f4bf Author: Daniel Asteljoki <daniel.asteljoki@gmail.com> Date: Wed Feb 6 13:34:26 2019 +0200 Rebalanced Humpback battery grid, added toggles for using backup power commit 47617a6d54f933714dffeca5fa311776e9d0523c Author: itchyOwl <lauri.harkanen@gmail.com> Date: Wed Feb 6 13:17:57 2019 +0200 Remove the lowercase variant of moloch's config file from the source control. commit 640662835684464e4a66b106b1958e5a9fde8a0c Merge: 80e91f96b 7861d00a6 Author: itchyOwl <lauri.harkanen@gmail.com> Date: Wed Feb 6 13:10:00 2019 +0200 Merge branch 'dev' of https://github.com/Regalis11/Barotrauma into dev commit 80e91f96bf5f1e9f89c5a6e4695292298a802b06 Author: itchyOwl <lauri.harkanen@gmail.com> Date: Wed Feb 6 13:09:37 2019 +0200 Fix a null reference exception. commit 91b16aaa7aacc658cb36325ea85944802166ef53 Author: itchyOwl <lauri.harkanen@gmail.com> Date: Wed Feb 6 13:09:26 2019 +0200 Instead of having a bad sight, make the Hammerhead deaf. Add "provocative" priority tag, remove "sonar". Make slightly less aggressive towards weaker. commit a383c136f6f6915163e98c472ec7ba7f575ea479 Author: itchyOwl <lauri.harkanen@gmail.com> Date: Wed Feb 6 13:02:00 2019 +0200 Add "provocative" tag on Moloch and Mudraptor targeting priorities. Tweak moloch priorities a bit. commit 7861d00a609f2555a19f510d72591bd0330f607e Author: Joonas Rikkonen <poe.regalis@gmail.com> Date: Wed Feb 6 12:53:37 2019 +0200 Attempt to fix/diagnose "collection was modified; enumeration operation may not execute" exceptions when using the fixhulls command (see #1011). Haven't been able to reproduce this issue. commit 1d1321c60e8815b3beaffb81bfb9c5f5c2528297 Author: itchyOwl <lauri.harkanen@gmail.com> Date: Wed Feb 6 12:52:29 2019 +0200 Add "provocative" tag that can be used as a red flag for the monsters. Add the tag on the diving scooter. Also add an ai target with sound ranges. commit 8530f4c9e4b1c444687cadbf615a9ade0440262b Author: itchyOwl <lauri.harkanen@gmail.com> Date: Wed Feb 6 12:50:43 2019 +0200 Propulsion can now make sound that attracts the enemies. The sound is on when the propulsion is active. commit 291f12676e5148da1a83d4dd72071381c1ae73e3 Author: itchyOwl <lauri.harkanen@gmail.com> Date: Wed Feb 6 12:49:39 2019 +0200 If a target item is held by a character, attack the character instead. commit 2aeaa9eaa51f3ed3db71f7853efef37bf5998838 Author: itchyOwl <lauri.harkanen@gmail.com> Date: Wed Feb 6 12:46:27 2019 +0200 Allow to define min and max sound ranges. commit 3bf5d2383cbcc33fa862a79c06756e6d9f20a753 Author: itchyOwl <lauri.harkanen@gmail.com> Date: Wed Feb 6 12:42:57 2019 +0200 Adjust the ai debug info. commit 369355ffef340875335c0d81d9a2c9a4bfac898b Author: EdusFF <pitkanen.eetu@gmail.com> Date: Wed Feb 6 12:40:30 2019 +0200 ContextualTutorial Update cleanup commit 101387adc1308ad87e3134ab2960d3032f725735 Author: EdusFF <pitkanen.eetu@gmail.com> Date: Wed Feb 6 12:34:07 2019 +0200 Formatting commit cc44eff21d57d93e4b0a67249af2135e5782e3c3 Merge: 9a338a2d4 33d1cd1be Author: EdusFF <pitkanen.eetu@gmail.com> Date: Wed Feb 6 12:31:54 2019 +0200 Merge branch 'dev' of https://github.com/Regalis11/Barotrauma into dev commit 9a338a2d440ff12426171fe9c3121efb934b6803 Author: EdusFF <pitkanen.eetu@gmail.com> Date: Wed Feb 6 12:31:50 2019 +0200 Modified: ContextualTutorial dismissal logic to use buttons instead of the press any key logic commit 33d1cd1beb61862a91bce16ebeb5090a8969cf1b Author: Joonas Rikkonen <poe.regalis@gmail.com> Date: Wed Feb 6 12:07:21 2019 +0200 Fixed spectate button staying disabled if starting a round fails (due to a missing sub file for example). Closes #1066 commit 8935825146203725759463278e7776a42d84a6a0 Merge: 2cdc96214 9fd3de63b Author: EdusFF <pitkanen.eetu@gmail.com> Date: Wed Feb 6 11:45:06 2019 +0200 Merge branch 'dev' of https://github.com/Regalis11/Barotrauma into dev commit 2cdc96214e2285bfa83a566ed8bc2aed4156c31d Author: EdusFF <pitkanen.eetu@gmail.com> Date: Wed Feb 6 11:44:56 2019 +0200 Added: Saving of the download size to the Workshop.Item, allows displaying the file size for non-downloaded content in SteamWorshopScreen. Closes #1052 commit 9fd3de63bc08e06a924bf5ec8a8b2938a647282f Author: Joonas Rikkonen <poe.regalis@gmail.com> Date: Wed Feb 6 11:34:38 2019 +0200 Watchmen cannot be dragged or grabbed, fixed watchmen imploding continuously if they end up outside. Closes #1072 commit eb3fca43d77e79f04e0ae80daac53b7e2c1e37f7 Author: Joonas Rikkonen <poe.regalis@gmail.com> Date: Wed Feb 6 11:14:06 2019 +0200 Fixed server not sending PowerContainer events until the charge of the PowerContainer has changed by more then 100% (i.e. never). Closes #1068 commit 5b3b71bab75489714f72ce55621f6da7d5ec8d94 Author: Joonas Rikkonen <poe.regalis@gmail.com> Date: Wed Feb 6 10:59:09 2019 +0200 Prevent locations from being generated too close to each other. Closes #1048 commit b032b36a50b60432f565cab0178de749585562ad Author: Joonas Rikkonen <poe.regalis@gmail.com> Date: Wed Feb 6 10:48:43 2019 +0200 Fixed a couple of errors in the translation instructions in EnglishVanilla.xml commit a31b2f257ef863f2cdd1504a3a15356f95262225 Author: itchyOwl <lauri.harkanen@gmail.com> Date: Wed Feb 6 09:34:11 2019 +0200 Show inventory icons in the sprite editor. commit fb7a69d6179824dde0a44d27ce5143a1a25d0147 Author: Roni Kovaniemi <roni.kovaniemi@gmail.com> Date: Wed Feb 6 02:18:44 2019 +0200 Improved background smoke texture commit 888e86a0e7d6e6a70feb2b87ea16cee17adcfd76 Author: Juan Pablo Arce <juanjp600@users.noreply.github.com> Date: Tue Feb 5 11:36:06 2019 -0300 whoops strikes again commit 67e94c6bb9e59b20bc1b9f3cb796780d1c2141f7 Author: itchyOwl <lauri.harkanen@gmail.com> Date: Tue Feb 5 16:32:45 2019 +0200 Adjust the min and max values for the sight range and add a todo note. commit ad0becdf175a66c963b2cbea5259b435c250ffa6 Author: itchyOwl <lauri.harkanen@gmail.com> Date: Tue Feb 5 16:31:47 2019 +0200 Refactor the sound range calculation. It was way off. commit adc0aa96be5426dbb845e4138acab87c44c935ba Author: itchyOwl <lauri.harkanen@gmail.com> Date: Tue Feb 5 16:31:18 2019 +0200 Improve the ai target debug info. commit 9230ba0865896d5740898993ab3389659a4cbb4a Author: Juan Pablo Arce <juanjp600@users.noreply.github.com> Date: Tue Feb 5 10:53:51 2019 -0300 Attempted audio buffer queue fix commit dfbc61628de37a60acbaa208934957a9d892eb99 Author: Eetu <pitkanen.eetu@gmail.com> Date: Tue Feb 5 15:18:34 2019 +0200 Fixed: Rubber ducks not floating like a good duck should commit 8b8523dad99b5c1db271ac13e48975487a7c7c99 Merge: 509c67594 c0156c3d3 Author: Eetu <pitkanen.eetu@gmail.com> Date: Tue Feb 5 14:34:59 2019 +0200 Merge branch 'dev' of https://github.com/Regalis11/Barotrauma into dev commit 509c6759484750d44a154a7f1703f92d0d6e1692 Author: Eetu <pitkanen.eetu@gmail.com> Date: Tue Feb 5 14:34:53 2019 +0200 Fixed: Holdable items retaining their pushing ability even when the user is stunned or unconscious. Closes #1061 commit c0156c3d350b64309c8068f437ddd57765f0b911 Author: itchyOwl <lauri.harkanen@gmail.com> Date: Tue Feb 5 13:46:32 2019 +0200 If no limb is selected, select the limb with the most critical affliction. Re-evaluate when new affliction is received. Sort afflictions so that dmg/sec is prioritized. Implements the feature request #1033. commit 4a056c6e9b78f3d6f43574b1b9ff5493d36565b0 Author: Joonas Rikkonen <poe.regalis@gmail.com> Date: Tue Feb 5 13:25:57 2019 +0200 Fixed order messages not being visible in single player if the character issuing the order has no headset. Closes #1030 commit 357b14fb4f4b1a56a04d192c17a2ce8e0ab7405e Author: ezjamsen <ezjames.fi@gmail.com> Date: Tue Feb 5 12:52:40 2019 +0200 new load tips commit 1f158760e1ed79968f10647c0a2931d2c603281e Author: ezjamsen <ezjames.fi@gmail.com> Date: Tue Feb 5 12:52:20 2019 +0200 minor formatting tweak to xml commit c53438151043174e18fbfe979ac3b3b862d24255 Author: Joonas Rikkonen <poe.regalis@gmail.com> Date: Tue Feb 5 12:48:47 2019 +0200 Stop Steam auth session of a client when they disconnect. Probably fixes servers reporting incorrect player counts (#1049)? commit 2073b170e4fdd5cedd998ff9d01f37842995194b Merge: 9914631c7 9b912a7bf Author: Eetu <pitkanen.eetu@gmail.com> Date: Tue Feb 5 12:43:05 2019 +0200 Merge branch 'dev' of https://github.com/Regalis11/Barotrauma into dev commit 9914631c7eb30c02913cd4ed44f7b7827169ad83 Author: Eetu <pitkanen.eetu@gmail.com> Date: Tue Feb 5 12:42:53 2019 +0200 Fixed: Fabricator allowing new items to be created when the output is not empty, resulting in wasted materials. commit 9b912a7bf16bd121bbe8b7eae20f4a253a9e1eba Author: Joonas Rikkonen <poe.regalis@gmail.com> Date: Tue Feb 5 12:33:00 2019 +0200 Fixed LOS effect not working on ruins when looking at them from inside a sub commit aeaf190c6d3b45d4d12654926acbe223dc4f5888 Author: Joonas Rikkonen <poe.regalis@gmail.com> Date: Tue Feb 5 11:57:17 2019 +0200 Pressing the radio chat hotkey doesn't deselect the chatbox. Closes #1044
1823 lines
76 KiB
C#
1823 lines
76 KiB
C#
using Barotrauma.Extensions;
|
|
using Barotrauma.Networking;
|
|
using Microsoft.Xna.Framework;
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace Barotrauma
|
|
{
|
|
partial class NetLobbyScreen : Screen
|
|
{
|
|
private GUIFrame infoFrame, chatFrame, playerListFrame;
|
|
private GUIFrame myCharacterFrame;
|
|
private GUIListBox playerList;
|
|
|
|
private GUIListBox subList, modeList, chatBox;
|
|
public GUIListBox ChatBox
|
|
{
|
|
get
|
|
{
|
|
return chatBox;
|
|
}
|
|
}
|
|
|
|
private GUIScrollBar levelDifficultyScrollBar;
|
|
|
|
private GUIButton[] traitorProbabilityButtons;
|
|
private GUITextBlock traitorProbabilityText;
|
|
|
|
private GUIButton[] botCountButtons;
|
|
private GUITextBlock botCountText;
|
|
|
|
private GUIButton[] botSpawnModeButtons;
|
|
private GUITextBlock botSpawnModeText;
|
|
|
|
private GUIButton[] missionTypeButtons;
|
|
private GUIComponent missionTypeContainer;
|
|
|
|
private GUIListBox jobList;
|
|
|
|
private GUITextBox textBox, seedBox;
|
|
public GUITextBox TextBox
|
|
{
|
|
get
|
|
{
|
|
return textBox;
|
|
}
|
|
}
|
|
|
|
private GUIFrame defaultModeContainer, campaignContainer;
|
|
private GUIButton campaignViewButton, spectateButton, settingsButton;
|
|
|
|
private GUITickBox playYourself;
|
|
|
|
private GUIFrame playerInfoContainer;
|
|
private GUIButton jobInfoFrame;
|
|
private GUIButton playerFrame;
|
|
|
|
private GUITickBox autoRestartBox;
|
|
|
|
private GUIDropDown shuttleList;
|
|
private GUITickBox shuttleTickBox;
|
|
|
|
private CampaignUI campaignUI;
|
|
private GUIComponent campaignSetupUI;
|
|
|
|
private Sprite backgroundSprite;
|
|
|
|
private GUITextBox serverMessage;
|
|
|
|
private float autoRestartTimer;
|
|
|
|
//persistent characterinfo provided by the server
|
|
//(character settings cannot be edited when this is set)
|
|
private CharacterInfo campaignCharacterInfo;
|
|
public bool CampaignCharacterDiscarded
|
|
{
|
|
get;
|
|
private set;
|
|
}
|
|
|
|
//elements that can only be used by the host
|
|
private List<GUIComponent> clientDisabledElements = new List<GUIComponent>();
|
|
//elements that aren't shown client-side
|
|
private List<GUIComponent> clientHiddenElements = new List<GUIComponent>();
|
|
|
|
private bool AllowSubSelection
|
|
{
|
|
get
|
|
{
|
|
return GameMain.Server != null || GameMain.NetworkMember.Voting.AllowSubVoting ||
|
|
(GameMain.Client != null && GameMain.Client.HasPermission(ClientPermissions.SelectSub));
|
|
}
|
|
}
|
|
|
|
public GUITextBox ServerMessage
|
|
{
|
|
get { return serverMessage; }
|
|
}
|
|
|
|
public string ServerMessageText
|
|
{
|
|
get { return serverMessage.Text; }
|
|
set { serverMessage.Text = value; }
|
|
}
|
|
|
|
public GUIButton ShowLogButton
|
|
{
|
|
get;
|
|
private set;
|
|
}
|
|
|
|
public GUIListBox SubList
|
|
{
|
|
get { return subList; }
|
|
}
|
|
|
|
public GUIDropDown ShuttleList
|
|
{
|
|
get { return shuttleList; }
|
|
}
|
|
|
|
public GUITickBox ShuttleTickBox
|
|
{
|
|
get { return shuttleTickBox; }
|
|
}
|
|
|
|
public GUIListBox ModeList
|
|
{
|
|
get { return modeList; }
|
|
}
|
|
public int SelectedModeIndex
|
|
{
|
|
get { return modeList.SelectedIndex; }
|
|
set { modeList.Select(value); }
|
|
}
|
|
|
|
public GUIListBox PlayerList
|
|
{
|
|
get { return playerList; }
|
|
}
|
|
|
|
public GUIButton StartButton
|
|
{
|
|
get;
|
|
private set;
|
|
}
|
|
|
|
public bool StartButtonEnabled
|
|
{
|
|
get { return StartButton.Enabled; }
|
|
set { StartButton.Enabled = value; }
|
|
}
|
|
|
|
public GUITickBox ReadyToStartBox
|
|
{
|
|
get;
|
|
private set;
|
|
}
|
|
|
|
public GUIFrame MyCharacterFrame
|
|
{
|
|
get { return myCharacterFrame; }
|
|
}
|
|
|
|
public bool MyCharacterFrameOpen;
|
|
|
|
public GUIFrame InfoFrame
|
|
{
|
|
get { return infoFrame; }
|
|
}
|
|
|
|
public Submarine SelectedSub
|
|
{
|
|
get { return subList.SelectedData as Submarine; }
|
|
set { subList.Select(value); }
|
|
}
|
|
|
|
public Submarine SelectedShuttle
|
|
{
|
|
get { return shuttleList.SelectedData as Submarine; }
|
|
}
|
|
|
|
public bool UsingShuttle
|
|
{
|
|
get { return shuttleTickBox.Selected; }
|
|
set { shuttleTickBox.Selected = value; if (GameMain.Client != null) shuttleTickBox.Enabled = false; }
|
|
}
|
|
|
|
public GameModePreset SelectedMode
|
|
{
|
|
get { return modeList.SelectedData as GameModePreset; }
|
|
}
|
|
|
|
public int MissionTypeIndex
|
|
{
|
|
get { return (int)missionTypeContainer.UserData; }
|
|
set { missionTypeContainer.UserData = value; }
|
|
}
|
|
|
|
public List<JobPrefab> JobPreferences
|
|
{
|
|
get
|
|
{
|
|
List<JobPrefab> jobPreferences = new List<JobPrefab>();
|
|
foreach (GUIComponent child in jobList.Content.Children)
|
|
{
|
|
JobPrefab jobPrefab = child.UserData as JobPrefab;
|
|
if (jobPrefab == null) continue;
|
|
jobPreferences.Add(jobPrefab);
|
|
}
|
|
return jobPreferences;
|
|
}
|
|
}
|
|
|
|
public string LevelSeed
|
|
{
|
|
get
|
|
{
|
|
return levelSeed;
|
|
}
|
|
set
|
|
{
|
|
if (levelSeed == value) return;
|
|
|
|
levelSeed = value;
|
|
backgroundSprite = LocationType.Random(levelSeed)?.GetPortrait(ToolBox.StringToInt(levelSeed));
|
|
seedBox.Text = levelSeed;
|
|
|
|
lastUpdateID++;
|
|
}
|
|
}
|
|
|
|
public string AutoRestartText()
|
|
{
|
|
if (GameMain.Server != null)
|
|
{
|
|
if (!GameMain.Server.AutoRestart || GameMain.Server.ConnectedClients.Count == 0) return "";
|
|
return TextManager.Get("RestartingIn") + " " + ToolBox.SecondsToReadableTime(Math.Max(GameMain.Server.AutoRestartTimer, 0));
|
|
}
|
|
|
|
if (autoRestartTimer == 0.0f) return "";
|
|
return TextManager.Get("RestartingIn") + " " + ToolBox.SecondsToReadableTime(Math.Max(autoRestartTimer, 0));
|
|
}
|
|
|
|
public NetLobbyScreen()
|
|
{
|
|
defaultModeContainer = new GUIFrame(new RectTransform(new Vector2(0.95f, 0.95f), Frame.RectTransform, Anchor.Center), style: null);
|
|
campaignContainer = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.75f), Frame.RectTransform, Anchor.TopCenter), style: null)
|
|
{
|
|
Visible = false
|
|
};
|
|
|
|
float panelSpacing = 0.02f;
|
|
|
|
//server info panel ------------------------------------------------------------
|
|
|
|
infoFrame = new GUIFrame(new RectTransform(new Vector2(0.7f, 0.65f), defaultModeContainer.RectTransform));
|
|
var infoFrameContent = new GUIFrame(new RectTransform(new Vector2(0.95f, 0.9f), infoFrame.RectTransform, Anchor.Center), style: null);
|
|
|
|
//chatbox ----------------------------------------------------------------------
|
|
chatFrame = new GUIFrame(new RectTransform(new Vector2(0.7f, 0.35f - panelSpacing), defaultModeContainer.RectTransform, Anchor.BottomLeft));
|
|
GUIFrame paddedChatFrame = new GUIFrame(new RectTransform(new Vector2(0.95f, 0.85f), chatFrame.RectTransform, Anchor.Center), style: null);
|
|
|
|
chatBox = new GUIListBox(new RectTransform(new Point(paddedChatFrame.Rect.Width, paddedChatFrame.Rect.Height - 30), paddedChatFrame.RectTransform) { IsFixedSize = false });
|
|
textBox = new GUITextBox(new RectTransform(new Point(paddedChatFrame.Rect.Width, 20), paddedChatFrame.RectTransform, Anchor.BottomLeft) { IsFixedSize = false })
|
|
{
|
|
MaxTextLength = ChatMessage.MaxLength,
|
|
Font = GUI.SmallFont
|
|
};
|
|
|
|
textBox.OnEnterPressed = (tb, userdata) => { GameMain.NetworkMember?.EnterChatMessage(tb, userdata); return true; };
|
|
textBox.OnTextChanged += (tb, userdata) => { GameMain.NetworkMember?.TypingChatMessage(tb, userdata); return true; };
|
|
|
|
//player info panel ------------------------------------------------------------
|
|
|
|
myCharacterFrame = new GUIFrame(new RectTransform(new Vector2(0.3f - panelSpacing, 0.65f), defaultModeContainer.RectTransform, Anchor.TopRight));
|
|
playerInfoContainer = new GUIFrame(new RectTransform(new Vector2(0.9f, 0.9f), myCharacterFrame.RectTransform, Anchor.Center), style: null);
|
|
|
|
playYourself = new GUITickBox(new RectTransform(new Vector2(0.06f, 0.06f), myCharacterFrame.RectTransform) { RelativeOffset = new Vector2(0.05f,0.05f) },
|
|
TextManager.Get("PlayYourself"))
|
|
{
|
|
OnSelected = (tickBox) => { SetPlayYourself(tickBox.Selected); return true; },
|
|
UserData = "playyourself"
|
|
};
|
|
|
|
var toggleMyPlayerFrame = new GUIButton(new RectTransform(new Point(25, 70), myCharacterFrame.RectTransform, Anchor.TopLeft, Pivot.TopRight), "", style: "GUIButtonHorizontalArrow");
|
|
toggleMyPlayerFrame.OnClicked += (GUIButton btn, object userdata) =>
|
|
{
|
|
MyCharacterFrameOpen = !MyCharacterFrameOpen;
|
|
foreach (GUIComponent child in btn.Children)
|
|
{
|
|
child.SpriteEffects = MyCharacterFrameOpen ? SpriteEffects.FlipHorizontally : SpriteEffects.None;
|
|
}
|
|
return true;
|
|
};
|
|
|
|
//player list ------------------------------------------------------------------
|
|
|
|
playerListFrame = new GUIFrame(new RectTransform(new Vector2(0.3f - panelSpacing, 0.35f - panelSpacing), defaultModeContainer.RectTransform, Anchor.BottomRight));
|
|
GUIFrame paddedPlayerListFrame = new GUIFrame(new RectTransform(new Vector2(0.9f, 0.85f), playerListFrame.RectTransform, Anchor.Center), style: null);
|
|
|
|
playerList = new GUIListBox(new RectTransform(Vector2.One, paddedPlayerListFrame.RectTransform))
|
|
{
|
|
OnSelected = SelectPlayer
|
|
};
|
|
|
|
//--------------------------------------------------------------------------------------------------------------------------------
|
|
//infoframe contents
|
|
//--------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
var infoColumnContainer = new GUILayoutGroup(new RectTransform(new Vector2(0.7f - 0.02f, 0.75f), infoFrameContent.RectTransform, Anchor.BottomLeft),
|
|
isHorizontal: true, childAnchor: Anchor.BottomLeft)
|
|
{ RelativeSpacing = 0.02f, Stretch = true };
|
|
var leftInfoColumn = new GUILayoutGroup(new RectTransform(new Vector2(0.35f, 1.0f), infoColumnContainer.RectTransform, Anchor.BottomLeft))
|
|
{ RelativeSpacing = 0.02f, Stretch = true };
|
|
var midInfoColumn = new GUILayoutGroup(new RectTransform(new Vector2(0.35f, 1.0f), infoColumnContainer.RectTransform, Anchor.BottomLeft))
|
|
{ RelativeSpacing = 0.02f, Stretch = true };
|
|
|
|
var rightInfoColumn = new GUILayoutGroup(new RectTransform(new Vector2(0.3f, 0.85f), infoFrameContent.RectTransform, Anchor.TopRight))
|
|
{ RelativeSpacing = 0.02f, Stretch = true };
|
|
|
|
var topButtonContainer = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.07f), rightInfoColumn.RectTransform), isHorizontal: true, childAnchor: Anchor.TopRight)
|
|
{
|
|
RelativeSpacing = 0.05f,
|
|
Stretch = true
|
|
};
|
|
|
|
//spacing
|
|
new GUIFrame(new RectTransform(new Vector2(1.0f, 0.03f), rightInfoColumn.RectTransform), style: null);
|
|
|
|
//server info ------------------------------------------------------------------
|
|
|
|
var serverName = new GUITextBox(new RectTransform(new Vector2(0.3f, 0.05f), infoFrameContent.RectTransform))
|
|
{
|
|
TextGetter = GetServerName,
|
|
Enabled = GameMain.Server != null,
|
|
};
|
|
serverName.OnTextChanged += ChangeServerName;
|
|
clientDisabledElements.Add(serverName);
|
|
|
|
serverMessage = new GUITextBox(new RectTransform(new Vector2(infoColumnContainer.RectTransform.RelativeSize.X, 0.15f), infoFrameContent.RectTransform) { RelativeOffset = new Vector2(0.0f, 0.07f) })
|
|
{
|
|
Wrap = true
|
|
};
|
|
serverMessage.OnTextChanged += UpdateServerMessage;
|
|
clientDisabledElements.Add(serverMessage);
|
|
|
|
settingsButton = new GUIButton(new RectTransform(new Vector2(0.5f, 1.0f), topButtonContainer.RectTransform, Anchor.TopRight),
|
|
TextManager.Get("ServerSettingsButton"));
|
|
clientHiddenElements.Add(settingsButton);
|
|
|
|
ShowLogButton = new GUIButton(new RectTransform(new Vector2(0.5f, 1.0f), topButtonContainer.RectTransform, Anchor.TopRight),
|
|
TextManager.Get("ServerLog"))
|
|
{
|
|
OnClicked = (GUIButton button, object userData) =>
|
|
{
|
|
if (GameMain.NetworkMember.ServerLog.LogFrame == null)
|
|
{
|
|
GameMain.NetworkMember.ServerLog.CreateLogFrame();
|
|
}
|
|
else
|
|
{
|
|
GameMain.NetworkMember.ServerLog.LogFrame = null;
|
|
GUI.KeyboardDispatcher.Subscriber = null;
|
|
}
|
|
return true;
|
|
}
|
|
};
|
|
clientHiddenElements.Add(ShowLogButton);
|
|
|
|
//submarine list ------------------------------------------------------------------
|
|
|
|
var subLabel = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), leftInfoColumn.RectTransform), TextManager.Get("Submarine"));
|
|
subList = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.9f), leftInfoColumn.RectTransform))
|
|
{
|
|
OnSelected = VotableClicked
|
|
};
|
|
|
|
var voteText = new GUITextBlock(new RectTransform(new Vector2(0.5f, 1.0f), subLabel.RectTransform, Anchor.TopRight),
|
|
TextManager.Get("Votes"), textAlignment: Alignment.CenterRight)
|
|
{
|
|
UserData = "subvotes",
|
|
Visible = false
|
|
};
|
|
|
|
//respawn shuttle ------------------------------------------------------------------
|
|
|
|
shuttleTickBox = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.05f), midInfoColumn.RectTransform), TextManager.Get("RespawnShuttle"))
|
|
{
|
|
Selected = true,
|
|
OnSelected = (GUITickBox box) =>
|
|
{
|
|
shuttleList.Enabled = box.Selected;
|
|
if (GameMain.Server != null) lastUpdateID++;
|
|
return true;
|
|
}
|
|
};
|
|
shuttleList = new GUIDropDown(new RectTransform(new Vector2(1.0f, 0.05f), midInfoColumn.RectTransform), elementCount: 10);
|
|
|
|
//gamemode ------------------------------------------------------------------
|
|
|
|
var modeLabel = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), midInfoColumn.RectTransform), TextManager.Get("GameMode"));
|
|
modeList = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.4f), midInfoColumn.RectTransform))
|
|
{
|
|
OnSelected = VotableClicked
|
|
};
|
|
|
|
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), midInfoColumn.RectTransform),
|
|
"Coming up: Multiplayer campaign", textAlignment: Alignment.Center, style: "ListBoxElement")
|
|
{
|
|
ToolTip = "Multiplayer campaign mode is not available in this version of Barotrauma. Coming up in the Early Access release!"
|
|
};
|
|
|
|
voteText = new GUITextBlock(new RectTransform(new Vector2(0.5f, 1.0f), modeLabel.RectTransform, Anchor.TopRight),
|
|
TextManager.Get("Votes"), textAlignment: Alignment.CenterRight)
|
|
{
|
|
UserData = "modevotes",
|
|
Visible = false
|
|
};
|
|
|
|
foreach (GameModePreset mode in GameModePreset.List)
|
|
{
|
|
if (mode.IsSinglePlayer) continue;
|
|
|
|
GUITextBlock textBlock = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.2f), modeList.Content.RectTransform),
|
|
mode.Name, style: "ListBoxElement", textAlignment: Alignment.CenterLeft)
|
|
{
|
|
ToolTip = mode.Description,
|
|
UserData = mode
|
|
};
|
|
}
|
|
|
|
//mission type ------------------------------------------------------------------
|
|
|
|
missionTypeContainer = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.05f), midInfoColumn.RectTransform), isHorizontal: true)
|
|
{
|
|
UserData = 0,
|
|
Visible = false,
|
|
Stretch = true
|
|
};
|
|
|
|
var missionTypeText = new GUITextBlock(new RectTransform(new Vector2(0.3f, 1.0f), missionTypeContainer.RectTransform),
|
|
TextManager.Get("MissionType"));
|
|
missionTypeButtons = new GUIButton[2];
|
|
missionTypeButtons[0] = new GUIButton(new RectTransform(new Vector2(0.1f, 1.0f), missionTypeContainer.RectTransform), "<")
|
|
{
|
|
UserData = -1
|
|
};
|
|
new GUITextBlock(new RectTransform(new Vector2(0.4f, 1.0f), missionTypeContainer.RectTransform),
|
|
TextManager.Get("MissionType.Random"), textAlignment: Alignment.Center)
|
|
{
|
|
UserData = 0
|
|
};
|
|
missionTypeButtons[1] = new GUIButton(new RectTransform(new Vector2(0.1f, 1.0f), missionTypeContainer.RectTransform), ">")
|
|
{
|
|
UserData = 1
|
|
};
|
|
clientDisabledElements.AddRange(missionTypeButtons);
|
|
|
|
//seed ------------------------------------------------------------------
|
|
|
|
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), rightInfoColumn.RectTransform), TextManager.Get("LevelSeed"));
|
|
seedBox = new GUITextBox(new RectTransform(new Vector2(1.0f, 0.05f), rightInfoColumn.RectTransform));
|
|
seedBox.OnTextChanged += SelectSeed;
|
|
clientDisabledElements.Add(seedBox);
|
|
LevelSeed = ToolBox.RandomSeed(8);
|
|
|
|
//level difficulty ------------------------------------------------------------------
|
|
|
|
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), rightInfoColumn.RectTransform), TextManager.Get("LevelDifficulty"));
|
|
levelDifficultyScrollBar = new GUIScrollBar(new RectTransform(new Vector2(1.0f, 0.05f), rightInfoColumn.RectTransform), barSize: 0.1f);
|
|
clientDisabledElements.Add(levelDifficultyScrollBar);
|
|
|
|
//traitor probability ------------------------------------------------------------------
|
|
|
|
new GUIFrame(new RectTransform(new Vector2(1.0f, 0.03f), rightInfoColumn.RectTransform), style: null); //spacing
|
|
|
|
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), rightInfoColumn.RectTransform), TextManager.Get("Traitors"));
|
|
|
|
var traitorProbContainer = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.05f), rightInfoColumn.RectTransform), isHorizontal: true);
|
|
traitorProbabilityButtons = new GUIButton[2];
|
|
traitorProbabilityButtons[0] = new GUIButton(new RectTransform(new Vector2(0.1f, 1.0f), traitorProbContainer.RectTransform), "<")
|
|
{
|
|
UserData = -1
|
|
};
|
|
traitorProbabilityText = new GUITextBlock(new RectTransform(new Vector2(0.5f, 1.0f), traitorProbContainer.RectTransform), TextManager.Get("No"), textAlignment: Alignment.Center);
|
|
traitorProbabilityButtons[1] = new GUIButton(new RectTransform(new Vector2(0.1f, 1.0f), traitorProbContainer.RectTransform), ">")
|
|
{
|
|
UserData = 1
|
|
};
|
|
clientDisabledElements.AddRange(traitorProbabilityButtons);
|
|
|
|
//bot count ------------------------------------------------------------------
|
|
|
|
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), rightInfoColumn.RectTransform), TextManager.Get("BotCount"));
|
|
var botCountContainer = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.05f), rightInfoColumn.RectTransform), isHorizontal: true);
|
|
botCountButtons = new GUIButton[2];
|
|
botCountButtons[0] = new GUIButton(new RectTransform(new Vector2(0.1f, 1.0f), botCountContainer.RectTransform), "<")
|
|
{
|
|
UserData = -1
|
|
};
|
|
botCountText = new GUITextBlock(new RectTransform(new Vector2(0.5f, 1.0f), botCountContainer.RectTransform), "0", textAlignment: Alignment.Center);
|
|
botCountButtons[1] = new GUIButton(new RectTransform(new Vector2(0.1f, 1.0f), botCountContainer.RectTransform), ">")
|
|
{
|
|
UserData = 1
|
|
};
|
|
clientDisabledElements.AddRange(botCountButtons);
|
|
|
|
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), rightInfoColumn.RectTransform), TextManager.Get("BotSpawnMode"));
|
|
var botSpawnModeContainer = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.05f), rightInfoColumn.RectTransform), isHorizontal: true);
|
|
botSpawnModeButtons = new GUIButton[2];
|
|
botSpawnModeButtons[0] = new GUIButton(new RectTransform(new Vector2(0.1f, 1.0f), botSpawnModeContainer.RectTransform), "<")
|
|
{
|
|
UserData = -1
|
|
};
|
|
botSpawnModeText = new GUITextBlock(new RectTransform(new Vector2(0.5f, 1.0f), botSpawnModeContainer.RectTransform), "", textAlignment: Alignment.Center);
|
|
botSpawnModeButtons[1] = new GUIButton(new RectTransform(new Vector2(0.1f, 1.0f), botSpawnModeContainer.RectTransform), ">")
|
|
{
|
|
UserData = 1
|
|
};
|
|
clientDisabledElements.AddRange(botSpawnModeButtons);
|
|
|
|
//misc buttons ------------------------------------------------------------------
|
|
|
|
new GUIFrame(new RectTransform(new Vector2(1.0f, 0.03f), rightInfoColumn.RectTransform), style: null); //spacing
|
|
|
|
autoRestartBox = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.05f), rightInfoColumn.RectTransform), TextManager.Get("AutoRestart"))
|
|
{
|
|
OnSelected = ToggleAutoRestart
|
|
};
|
|
clientDisabledElements.Add(autoRestartBox);
|
|
var restartText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), rightInfoColumn.RectTransform), "", font: GUI.SmallFont)
|
|
{
|
|
TextGetter = AutoRestartText
|
|
};
|
|
|
|
StartButton = new GUIButton(new RectTransform(new Vector2(0.3f, 0.1f), infoFrameContent.RectTransform, Anchor.BottomRight),
|
|
TextManager.Get("StartGameButton"), style: "GUIButtonLarge");
|
|
clientHiddenElements.Add(StartButton);
|
|
|
|
ReadyToStartBox = new GUITickBox(new RectTransform(new Vector2(0.3f, 0.06f), infoFrameContent.RectTransform, Anchor.BottomRight),
|
|
TextManager.Get("ReadyToStartTickBox"), GUI.SmallFont)
|
|
{
|
|
Visible = false
|
|
};
|
|
|
|
campaignViewButton = new GUIButton(new RectTransform(new Vector2(0.3f, 0.1f), infoFrameContent.RectTransform, Anchor.BottomRight) { RelativeOffset = new Vector2(0.0f, 0.06f) },
|
|
TextManager.Get("CampaignView"), style: "GUIButtonLarge")
|
|
{
|
|
OnClicked = (btn, obj) => { ToggleCampaignView(true); return true; },
|
|
Visible = false
|
|
};
|
|
|
|
spectateButton = new GUIButton(new RectTransform(new Vector2(0.3f, 0.1f), infoFrameContent.RectTransform, Anchor.BottomRight),
|
|
TextManager.Get("SpectateButton"), style: "GUIButtonLarge");
|
|
}
|
|
|
|
public override void Deselect()
|
|
{
|
|
textBox.Deselect();
|
|
myCharacterFrame.GetChild<GUIButton>().Visible = true;
|
|
CampaignCharacterDiscarded = false;
|
|
}
|
|
|
|
public override void Select()
|
|
{
|
|
if (GameMain.NetworkMember == null) return;
|
|
Character.Controlled = null;
|
|
GameMain.LightManager.LosEnabled = false;
|
|
|
|
CampaignCharacterDiscarded = false;
|
|
|
|
textBox.Select();
|
|
|
|
myCharacterFrame.RectTransform.AbsoluteOffset = new Point(0, 0);
|
|
myCharacterFrame.GetChild<GUIButton>().Visible = false;
|
|
|
|
subList.Enabled = AllowSubSelection || GameMain.Server != null;
|
|
shuttleList.Enabled = AllowSubSelection || GameMain.Server != null;
|
|
|
|
modeList.Enabled =
|
|
GameMain.Server != null || GameMain.NetworkMember.Voting.AllowModeVoting ||
|
|
(GameMain.Client != null && GameMain.Client.HasPermission(ClientPermissions.SelectMode));
|
|
|
|
ServerName = (GameMain.Server == null) ? ServerName : GameMain.Server.Name;
|
|
|
|
//disable/hide elements the clients are not supposed to use/see
|
|
clientDisabledElements.ForEach(c => c.Enabled = GameMain.Server != null);
|
|
clientHiddenElements.ForEach(c => c.Visible = GameMain.Server != null);
|
|
|
|
ShowLogButton.Visible =
|
|
GameMain.Server != null ||
|
|
(GameMain.Client != null && GameMain.Client.HasPermission(ClientPermissions.ServerLog));
|
|
|
|
if (GameMain.Client != null)
|
|
{
|
|
spectateButton.Visible = GameMain.Client.GameStarted;
|
|
ReadyToStartBox.Visible = !GameMain.Client.GameStarted;
|
|
ReadyToStartBox.Selected = false;
|
|
GameMain.Client.SetReadyToStart(ReadyToStartBox);
|
|
}
|
|
else
|
|
{
|
|
spectateButton.Visible = false;
|
|
ReadyToStartBox.Visible = false;
|
|
}
|
|
SetPlayYourself(playYourself.Selected);
|
|
|
|
if (IsServer && GameMain.Server != null)
|
|
{
|
|
List<Submarine> subsToShow = Submarine.SavedSubmarines.Where(s => !s.HasTag(SubmarineTag.HideInMenus)).ToList();
|
|
|
|
ReadyToStartBox.Visible = false;
|
|
StartButton.OnClicked = GameMain.Server.StartGameClicked;
|
|
settingsButton.OnClicked = GameMain.Server.ToggleSettingsFrame;
|
|
|
|
int prevSelectedSub = subList.SelectedIndex;
|
|
UpdateSubList(subList, subsToShow);
|
|
|
|
int prevSelectedShuttle = shuttleList.SelectedIndex;
|
|
UpdateSubList(shuttleList, subsToShow);
|
|
modeList.OnSelected = VotableClicked;
|
|
modeList.OnSelected = SelectMode;
|
|
subList.OnSelected = VotableClicked;
|
|
subList.OnSelected = SelectSub;
|
|
shuttleList.OnSelected = SelectSub;
|
|
|
|
levelDifficultyScrollBar.OnMoved = (GUIScrollBar scrollBar, float barScroll) =>
|
|
{
|
|
SetLevelDifficulty(barScroll * 100.0f);
|
|
return true;
|
|
};
|
|
|
|
traitorProbabilityButtons[0].OnClicked = traitorProbabilityButtons[1].OnClicked = ToggleTraitorsEnabled;
|
|
botCountButtons[0].OnClicked = botCountButtons[1].OnClicked = ChangeBotCount;
|
|
botSpawnModeButtons[0].OnClicked = botSpawnModeButtons[1].OnClicked = ChangeBotSpawnMode;
|
|
missionTypeButtons[0].OnClicked = missionTypeButtons[1].OnClicked = ToggleMissionType;
|
|
|
|
if (subList.SelectedComponent == null) subList.Select(Math.Max(0, prevSelectedSub));
|
|
if (shuttleList.Selected == null)
|
|
{
|
|
var shuttles = shuttleList.GetChildren().Where(c => c.UserData is Submarine && ((Submarine)c.UserData).HasTag(SubmarineTag.Shuttle));
|
|
if (prevSelectedShuttle == -1 && shuttles.Any())
|
|
{
|
|
shuttleList.SelectItem(shuttles.First().UserData);
|
|
}
|
|
else
|
|
{
|
|
shuttleList.Select(Math.Max(0, prevSelectedShuttle));
|
|
}
|
|
}
|
|
|
|
GameAnalyticsManager.SetCustomDimension01("multiplayer");
|
|
|
|
if (GameModePreset.List.Count > 0 && modeList.SelectedComponent == null) modeList.Select(0);
|
|
GameMain.Server.Voting.ResetVotes(GameMain.Server.ConnectedClients);
|
|
}
|
|
else if (GameMain.Client != null)
|
|
{
|
|
GameMain.Client.Voting.ResetVotes(GameMain.Client.ConnectedClients);
|
|
SetPlayYourself(true);
|
|
spectateButton.OnClicked = GameMain.Client.SpectateClicked;
|
|
ReadyToStartBox.OnSelected = GameMain.Client.SetReadyToStart;
|
|
}
|
|
|
|
GameMain.NetworkMember.EndVoteCount = 0;
|
|
GameMain.NetworkMember.EndVoteMax = 1;
|
|
|
|
base.Select();
|
|
}
|
|
|
|
public void RandomizeSettings()
|
|
{
|
|
if (GameMain.Server == null) return;
|
|
|
|
if (GameMain.Server.RandomizeSeed) LevelSeed = ToolBox.RandomSeed(8);
|
|
if (GameMain.Server.SubSelectionMode == SelectionMode.Random)
|
|
{
|
|
var nonShuttles = subList.Content.Children.Where(c => c.UserData is Submarine && !((Submarine)c.UserData).HasTag(SubmarineTag.Shuttle));
|
|
subList.Select(nonShuttles.GetRandom());
|
|
}
|
|
if (GameMain.Server.ModeSelectionMode == SelectionMode.Random)
|
|
{
|
|
var allowedGameModes = GameModePreset.List.FindAll(m => !m.IsSinglePlayer && m.Identifier != "multiplayercampaign");
|
|
modeList.Select(allowedGameModes[Rand.Range(0, allowedGameModes.Count)]);
|
|
}
|
|
}
|
|
|
|
public void ShowSpectateButton()
|
|
{
|
|
if (GameMain.Client == null) return;
|
|
spectateButton.Visible = true;
|
|
spectateButton.Enabled = true;
|
|
}
|
|
|
|
public void SetCampaignCharacterInfo(CharacterInfo characterInfo)
|
|
{
|
|
if (CampaignCharacterDiscarded) return;
|
|
|
|
campaignCharacterInfo = characterInfo;
|
|
if (campaignCharacterInfo != null)
|
|
{
|
|
UpdatePlayerFrame(campaignCharacterInfo, false);
|
|
}
|
|
else
|
|
{
|
|
UpdatePlayerFrame(null, true);
|
|
}
|
|
}
|
|
|
|
private void UpdatePlayerFrame(CharacterInfo characterInfo, bool allowEditing = true)
|
|
{
|
|
if (!playYourself.Selected) return;
|
|
if (characterInfo == null)
|
|
{
|
|
characterInfo =
|
|
new CharacterInfo(Character.HumanConfigFile, GameMain.NetworkMember.Name, GameMain.Config.CharacterGender, null)
|
|
{
|
|
Race = GameMain.Config.CharacterRace,
|
|
HeadSpriteId = GameMain.Config.CharacterHeadIndex,
|
|
HairIndex = GameMain.Config.CharacterHairIndex,
|
|
BeardIndex = GameMain.Config.CharacterBeardIndex,
|
|
MoustacheIndex = GameMain.Config.CharacterMoustacheIndex,
|
|
FaceAttachmentIndex = GameMain.Config.CharacterFaceAttachmentIndex,
|
|
};
|
|
// Need to reload the attachments because the indices may have changed
|
|
characterInfo.LoadHeadAttachments();
|
|
GameMain.NetworkMember.CharacterInfo = characterInfo;
|
|
}
|
|
|
|
playerInfoContainer.ClearChildren();
|
|
|
|
GUIComponent infoContainer = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.9f), playerInfoContainer.RectTransform, Anchor.BottomCenter), childAnchor: Anchor.TopCenter)
|
|
{ Stretch = true };
|
|
|
|
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.1f), infoContainer.RectTransform), characterInfo.Name, font: GUI.LargeFont, textAlignment: Alignment.Center, wrap: true);
|
|
|
|
GUIComponent headContainer = new GUILayoutGroup(new RectTransform(new Vector2(0.6f, 0.2f), infoContainer.RectTransform, Anchor.TopCenter), isHorizontal: true)
|
|
{
|
|
Stretch = true
|
|
};
|
|
|
|
if (allowEditing)
|
|
{
|
|
new GUIButton(new RectTransform(new Vector2(0.1f, 1.0f), headContainer.RectTransform), "", style: "GUIButtonHorizontalArrow")
|
|
{
|
|
UserData = -1,
|
|
OnClicked = ToggleHead
|
|
}.Children.ForEach(c => c.SpriteEffects = SpriteEffects.FlipHorizontally);
|
|
}
|
|
|
|
new GUICustomComponent(new RectTransform(new Vector2(0.3f, 1.0f), headContainer.RectTransform),
|
|
onDraw: (sb, component) => characterInfo.DrawIcon(sb, component.Rect.Center.ToVector2(), targetAreaSize: component.Rect.Size.ToVector2()));
|
|
|
|
if (allowEditing)
|
|
{
|
|
new GUIButton(new RectTransform(new Vector2(0.1f, 1.0f), headContainer.RectTransform), style: "GUIButtonHorizontalArrow")
|
|
{
|
|
UserData = 1,
|
|
OnClicked = ToggleHead
|
|
};
|
|
|
|
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), infoContainer.RectTransform),
|
|
TextManager.Get("Gender"), textAlignment: Alignment.Center);
|
|
GUIComponent genderContainer = new GUILayoutGroup(new RectTransform(new Vector2(0.5f, 0.06f), infoContainer.RectTransform), isHorizontal: true)
|
|
{
|
|
Stretch = true,
|
|
RelativeSpacing = 0.05f
|
|
};
|
|
|
|
GUIButton maleButton = new GUIButton(new RectTransform(new Vector2(0.5f, 1.0f), genderContainer.RectTransform),
|
|
TextManager.Get("Male"))
|
|
{
|
|
UserData = Gender.Male,
|
|
OnClicked = SwitchGender
|
|
};
|
|
|
|
GUIButton femaleButton = new GUIButton(new RectTransform(new Vector2(0.5f, 1.0f), genderContainer.RectTransform),
|
|
TextManager.Get("Female"))
|
|
{
|
|
UserData = Gender.Female,
|
|
OnClicked = SwitchGender
|
|
};
|
|
|
|
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.1f), infoContainer.RectTransform),
|
|
TextManager.Get("JobPreferences"));
|
|
|
|
jobList = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.4f), infoContainer.RectTransform))
|
|
{
|
|
Enabled = false
|
|
};
|
|
|
|
int i = 1;
|
|
foreach (string jobIdentifier in GameMain.Config.JobPreferences)
|
|
{
|
|
JobPrefab job = JobPrefab.List.Find(j => j.Identifier == jobIdentifier);
|
|
if (job == null || job.MaxNumber <= 0) continue;
|
|
|
|
var jobFrame = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.2f), jobList.Content.RectTransform), style: "ListBoxElement")
|
|
{
|
|
UserData = job
|
|
};
|
|
GUITextBlock jobText = new GUITextBlock(new RectTransform(new Vector2(0.66f, 1.0f), jobFrame.RectTransform, Anchor.CenterRight),
|
|
i + ". " + job.Name + " ", textAlignment: Alignment.CenterLeft);
|
|
|
|
var jobButtonContainer = new GUILayoutGroup(new RectTransform(new Vector2(0.3f, 0.8f), jobFrame.RectTransform, Anchor.CenterLeft) { RelativeOffset = new Vector2(0.02f, 0.0f) },
|
|
isHorizontal: true, childAnchor: Anchor.CenterLeft)
|
|
{
|
|
RelativeSpacing = 0.03f
|
|
};
|
|
|
|
int buttonSize = jobButtonContainer.Rect.Height;
|
|
GUIButton infoButton = new GUIButton(new RectTransform(new Point(buttonSize, buttonSize), jobButtonContainer.RectTransform), "?")
|
|
{
|
|
UserData = job,
|
|
OnClicked = ViewJobInfo
|
|
};
|
|
|
|
GUIButton upButton = new GUIButton(new RectTransform(new Point(buttonSize, buttonSize), jobButtonContainer.RectTransform), "")
|
|
{
|
|
UserData = -1,
|
|
OnClicked = ChangeJobPreference
|
|
};
|
|
new GUIImage(new RectTransform(new Vector2(0.8f, 0.8f), upButton.RectTransform, Anchor.Center), GUI.Arrow, scaleToFit: true);
|
|
|
|
GUIButton downButton = new GUIButton(new RectTransform(new Point(buttonSize, buttonSize), jobButtonContainer.RectTransform), "")
|
|
{
|
|
UserData = 1,
|
|
OnClicked = ChangeJobPreference
|
|
};
|
|
new GUIImage(new RectTransform(new Vector2(0.8f, 0.8f), downButton.RectTransform, Anchor.Center), GUI.Arrow, scaleToFit: true)
|
|
{
|
|
Rotation = MathHelper.Pi
|
|
};
|
|
}
|
|
|
|
UpdateJobPreferences(jobList);
|
|
}
|
|
else
|
|
{
|
|
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.15f), infoContainer.RectTransform), characterInfo.Job.Name, textAlignment: Alignment.Center, wrap: true);
|
|
|
|
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.1f), infoContainer.RectTransform), TextManager.Get("Skills"));
|
|
foreach (Skill skill in characterInfo.Job.Skills)
|
|
{
|
|
Color textColor = Color.White * (0.5f + skill.Level / 200.0f);
|
|
var skillText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.1f), infoContainer.RectTransform),
|
|
" - " + TextManager.Get("SkillName." + skill.Identifier) + ": " + (int)skill.Level, textColor);
|
|
}
|
|
|
|
//spacing
|
|
new GUIFrame(new RectTransform(new Vector2(1.0f, 0.15f), infoContainer.RectTransform), style: null);
|
|
|
|
new GUIButton(new RectTransform(new Vector2(0.8f, 0.1f), infoContainer.RectTransform, Anchor.BottomCenter), "Create new")
|
|
{
|
|
IgnoreLayoutGroups = true,
|
|
OnClicked = (btn, userdata) =>
|
|
{
|
|
var confirmation = new GUIMessageBox(TextManager.Get("NewCampaignCharacterHeader"), TextManager.Get("NewCampaignCharacterText"),
|
|
new string[] { TextManager.Get("Yes"), TextManager.Get("No") });
|
|
confirmation.Buttons[0].OnClicked += confirmation.Close;
|
|
confirmation.Buttons[0].OnClicked += (btn2, userdata2) =>
|
|
{
|
|
CampaignCharacterDiscarded = true;
|
|
campaignCharacterInfo = null;
|
|
UpdatePlayerFrame(null, true);
|
|
return true;
|
|
};
|
|
confirmation.Buttons[1].OnClicked += confirmation.Close;
|
|
return true;
|
|
}
|
|
};
|
|
}
|
|
}
|
|
|
|
public void SetPlayYourself(bool playYourself)
|
|
{
|
|
this.playYourself.Selected = playYourself;
|
|
if (playYourself)
|
|
{
|
|
UpdatePlayerFrame(campaignCharacterInfo, allowEditing: campaignCharacterInfo == null);
|
|
}
|
|
else
|
|
{
|
|
playerInfoContainer.ClearChildren();
|
|
|
|
GameMain.NetworkMember.CharacterInfo = null;
|
|
GameMain.NetworkMember.Character = null;
|
|
|
|
new GUITextBlock(new RectTransform(Vector2.One, playerInfoContainer.RectTransform, Anchor.Center),
|
|
TextManager.Get("PlayingAsSpectator"),
|
|
textAlignment: Alignment.Center);
|
|
}
|
|
}
|
|
|
|
public void SetAllowSpectating(bool allowSpectating)
|
|
{
|
|
//show the player config menu if spectating is not allowed
|
|
if (!allowSpectating)
|
|
{
|
|
SetPlayYourself(true);
|
|
}
|
|
//hide "play yourself" tickbox if spectating is not allowed
|
|
playYourself.Visible = allowSpectating;
|
|
}
|
|
|
|
public void SetAutoRestart(bool enabled, float timer = 0.0f)
|
|
{
|
|
autoRestartBox.Selected = enabled;
|
|
autoRestartTimer = timer;
|
|
}
|
|
|
|
public void ToggleAutoRestart()
|
|
{
|
|
autoRestartBox.Selected = !autoRestartBox.Selected;
|
|
ToggleAutoRestart(autoRestartBox);
|
|
}
|
|
|
|
private bool ToggleAutoRestart(GUITickBox tickBox)
|
|
{
|
|
if (GameMain.Server == null) return false;
|
|
|
|
GameMain.Server.AutoRestart = tickBox.Selected;
|
|
|
|
lastUpdateID++;
|
|
|
|
return true;
|
|
}
|
|
|
|
public void SetMissionType(int missionTypeIndex)
|
|
{
|
|
if (missionTypeIndex < 0 || missionTypeIndex >= Enum.GetValues(typeof(MissionType)).Length) return;
|
|
|
|
((GUITextBlock)missionTypeContainer.GetChild(2)).Text = TextManager.Get("MissionType." + ((MissionType)missionTypeIndex).ToString());
|
|
missionTypeContainer.UserData = ((MissionType)missionTypeIndex);
|
|
}
|
|
|
|
public bool ToggleMissionType(GUIButton button, object userData)
|
|
{
|
|
if (GameMain.Server == null) return false;
|
|
|
|
int missionTypeIndex = (int)missionTypeContainer.UserData;
|
|
missionTypeIndex += (int)userData;
|
|
|
|
if (missionTypeIndex < 0) missionTypeIndex = Enum.GetValues(typeof(MissionType)).Length - 1;
|
|
if (missionTypeIndex >= Enum.GetValues(typeof(MissionType)).Length) missionTypeIndex = 0;
|
|
|
|
SetMissionType(missionTypeIndex);
|
|
|
|
lastUpdateID++;
|
|
|
|
return true;
|
|
}
|
|
|
|
public bool ToggleTraitorsEnabled(GUIButton button, object userData)
|
|
{
|
|
ToggleTraitorsEnabled((int)userData);
|
|
return true;
|
|
}
|
|
|
|
public bool ChangeBotCount(GUIButton button, object userData)
|
|
{
|
|
if (GameMain.Server == null) return false;
|
|
SetBotCount(GameMain.Server.BotCount + (int)userData);
|
|
return true;
|
|
}
|
|
|
|
public bool ChangeBotSpawnMode(GUIButton button, object userData)
|
|
{
|
|
if (GameMain.Server == null) return false;
|
|
SetBotSpawnMode(GameMain.Server.BotSpawnMode == BotSpawnMode.Fill ? BotSpawnMode.Normal : BotSpawnMode.Fill);
|
|
return true;
|
|
}
|
|
|
|
private bool SelectSub(GUIComponent component, object obj)
|
|
{
|
|
if (GameMain.Server == null) return false;
|
|
|
|
lastUpdateID++;
|
|
|
|
var hash = obj is Submarine ? ((Submarine)obj).MD5Hash.Hash : "";
|
|
|
|
//hash will be null if opening the sub file failed -> don't select the sub
|
|
if (string.IsNullOrWhiteSpace(hash))
|
|
{
|
|
GUITextBlock submarineTextBlock = component.GetChild<GUITextBlock>();
|
|
if (submarineTextBlock != null)
|
|
{
|
|
submarineTextBlock.TextColor = Color.DarkRed * 0.8f;
|
|
submarineTextBlock.CanBeFocused = false;
|
|
}
|
|
else
|
|
{
|
|
DebugConsole.ThrowError("Failed to select submarine. Selected GUIComponent was of the type \"" + (component == null ? "null" : component.GetType().ToString()) + "\".");
|
|
GameAnalyticsManager.AddErrorEventOnce(
|
|
"NetLobbyScreen.SelectSub:InvalidComponent",
|
|
GameAnalyticsSDK.Net.EGAErrorSeverity.Error,
|
|
"Failed to select submarine. Selected GUIComponent was of the type \"" + (component == null ? "null" : component.GetType().ToString()) + "\".");
|
|
}
|
|
|
|
|
|
StartButton.Enabled = false;
|
|
|
|
return false;
|
|
}
|
|
|
|
StartButton.Enabled = true;
|
|
|
|
return true;
|
|
}
|
|
|
|
public void UpdateSubList(GUIComponent subList, List<Submarine> submarines)
|
|
{
|
|
if (subList == null) return;
|
|
|
|
subList.ClearChildren();
|
|
|
|
if (submarines.Count == 0 && GameMain.Server != null)
|
|
{
|
|
DebugConsole.ThrowError("No submarines found!");
|
|
}
|
|
|
|
foreach (Submarine sub in submarines)
|
|
{
|
|
AddSubmarine(subList, sub);
|
|
}
|
|
}
|
|
|
|
private void AddSubmarine(GUIComponent subList, Submarine sub)
|
|
{
|
|
if (subList is GUIListBox)
|
|
{
|
|
subList = ((GUIListBox)subList).Content;
|
|
}
|
|
else if (subList is GUIDropDown)
|
|
{
|
|
subList = ((GUIDropDown)subList).ListBox.Content;
|
|
}
|
|
|
|
var frame = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.1f), subList.RectTransform) { MinSize = new Point(0, 20) },
|
|
style: "ListBoxElement")
|
|
{
|
|
ToolTip = sub.Description,
|
|
UserData = sub
|
|
};
|
|
|
|
int buttonSize = (int)(frame.Rect.Height * 0.8f);
|
|
var subTextBlock = new GUITextBlock(new RectTransform(new Vector2(0.8f, 1.0f), frame.RectTransform, Anchor.CenterLeft) { AbsoluteOffset = new Point(buttonSize + 5, 0) },
|
|
ToolBox.LimitString(sub.Name, GUI.Font, subList.Rect.Width - 65), textAlignment: Alignment.CenterLeft)
|
|
{
|
|
CanBeFocused = false
|
|
};
|
|
|
|
var matchingSub = Submarine.SavedSubmarines.FirstOrDefault(s => s.Name == sub.Name && s.MD5Hash.Hash == sub.MD5Hash.Hash);
|
|
if (matchingSub == null) matchingSub = Submarine.SavedSubmarines.FirstOrDefault(s => s.Name == sub.Name);
|
|
|
|
if (matchingSub == null)
|
|
{
|
|
subTextBlock.TextColor = new Color(subTextBlock.TextColor, 0.5f);
|
|
frame.ToolTip = TextManager.Get("SubNotFound");
|
|
}
|
|
else if (matchingSub.MD5Hash.Hash != sub.MD5Hash.Hash)
|
|
{
|
|
subTextBlock.TextColor = new Color(subTextBlock.TextColor, 0.5f);
|
|
frame.ToolTip = TextManager.Get("SubDoesntMatch");
|
|
}
|
|
else
|
|
{
|
|
if (subList == shuttleList || subList == shuttleList.ListBox || subList == shuttleList.ListBox.Content)
|
|
{
|
|
subTextBlock.TextColor = new Color(subTextBlock.TextColor, sub.HasTag(SubmarineTag.Shuttle) ? 1.0f : 0.6f);
|
|
}
|
|
|
|
GUIButton infoButton = new GUIButton(new RectTransform(new Point(buttonSize, buttonSize), frame.RectTransform, Anchor.CenterLeft) { AbsoluteOffset = new Point((int)(buttonSize * 0.2f), 0) }, "?")
|
|
{
|
|
UserData = sub
|
|
};
|
|
infoButton.OnClicked += (component, userdata) =>
|
|
{
|
|
((Submarine)userdata).CreatePreviewWindow(new GUIMessageBox("", "", 550, 400));
|
|
return true;
|
|
};
|
|
}
|
|
|
|
if (sub.HasTag(SubmarineTag.Shuttle))
|
|
{
|
|
new GUITextBlock(new RectTransform(new Vector2(0.5f, 1.0f), frame.RectTransform, Anchor.CenterRight),
|
|
TextManager.Get("Shuttle"), textAlignment: Alignment.CenterRight, font: GUI.SmallFont)
|
|
{
|
|
TextColor = subTextBlock.TextColor * 0.8f,
|
|
ToolTip = subTextBlock.ToolTip,
|
|
CanBeFocused = false
|
|
};
|
|
//make shuttles more dim in the sub list (selecting a shuttle as the main sub is allowed but not recommended)
|
|
if (subList == this.subList.Content)
|
|
{
|
|
subTextBlock.TextColor *= 0.5f;
|
|
foreach (GUIComponent child in frame.Children)
|
|
{
|
|
child.Color *= 0.5f;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public bool VotableClicked(GUIComponent component, object userData)
|
|
{
|
|
if (GameMain.Client == null) return false;
|
|
|
|
VoteType voteType;
|
|
if (component.Parent == GameMain.NetLobbyScreen.SubList.Content)
|
|
{
|
|
if (!GameMain.Client.Voting.AllowSubVoting)
|
|
{
|
|
if (GameMain.Client.HasPermission(ClientPermissions.SelectSub))
|
|
{
|
|
GameMain.Client.RequestSelectSub(component.Parent.GetChildIndex(component));
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
voteType = VoteType.Sub;
|
|
}
|
|
else if (component.Parent == GameMain.NetLobbyScreen.ModeList.Content)
|
|
{
|
|
if (!((GameModePreset)userData).Votable) return false;
|
|
if (!GameMain.Client.Voting.AllowModeVoting)
|
|
{
|
|
if (GameMain.Client.HasPermission(ClientPermissions.SelectMode))
|
|
{
|
|
GameMain.Client.RequestSelectMode(component.Parent.GetChildIndex(component));
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
voteType = VoteType.Mode;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
|
|
GameMain.Client.Vote(voteType, userData);
|
|
|
|
return true;
|
|
}
|
|
|
|
public bool ChangeServerName(GUITextBox textBox, string text)
|
|
{
|
|
if (GameMain.Server == null) return false;
|
|
ServerName = text;
|
|
lastUpdateID++;
|
|
|
|
return true;
|
|
}
|
|
|
|
public bool UpdateServerMessage(GUITextBox textBox, string text)
|
|
{
|
|
if (GameMain.Server == null) return false;
|
|
|
|
lastUpdateID++;
|
|
|
|
return true;
|
|
}
|
|
|
|
public void AddPlayer(string name)
|
|
{
|
|
GUITextBlock textBlock = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.2f), playerList.Content.RectTransform),
|
|
name, textAlignment: Alignment.CenterLeft)
|
|
{
|
|
UserData = name
|
|
};
|
|
|
|
if (GameMain.Server != null) lastUpdateID++;
|
|
}
|
|
|
|
public void RemovePlayer(string name)
|
|
{
|
|
GUIComponent child = playerList.Content.GetChildByUserData(name);
|
|
if (child != null) playerList.RemoveChild(child);
|
|
if (GameMain.Server != null) lastUpdateID++;
|
|
}
|
|
|
|
private bool SelectPlayer(GUIComponent component, object obj)
|
|
{
|
|
var selectedClient = GameMain.NetworkMember.ConnectedClients.Find(c => c.Name == obj.ToString());
|
|
if (selectedClient == null) return false;
|
|
|
|
if (GameMain.Client != null)
|
|
{
|
|
if (selectedClient.ID == GameMain.Client.ID) return false;
|
|
|
|
if (!GameMain.Client.HasPermission(ClientPermissions.Ban) &&
|
|
!GameMain.Client.HasPermission(ClientPermissions.Kick) &&
|
|
!GameMain.Client.Voting.AllowVoteKick)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
playerFrame = new GUIButton(new RectTransform(Vector2.One, GUI.Canvas), style: "GUIBackgroundBlocker")
|
|
{
|
|
OnClicked = (btn, userdata) => { if (GUI.MouseOn == btn || GUI.MouseOn == btn.TextBlock) ClosePlayerFrame(btn, userdata); return true; }
|
|
};
|
|
|
|
var playerFrameInner = new GUIFrame(new RectTransform(GameMain.Server != null ? new Point(450, 370) : new Point(450, 150), playerFrame.RectTransform, Anchor.Center));
|
|
var paddedPlayerFrame = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 0.9f), playerFrameInner.RectTransform, Anchor.Center))
|
|
{
|
|
Stretch = true,
|
|
RelativeSpacing = 0.05f
|
|
};
|
|
|
|
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.1f), paddedPlayerFrame.RectTransform),
|
|
text: obj.ToString(), font: GUI.LargeFont);
|
|
|
|
if (GameMain.Server != null)
|
|
{
|
|
playerFrame.UserData = selectedClient;
|
|
|
|
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.1f), paddedPlayerFrame.RectTransform),
|
|
selectedClient.Connection.RemoteEndPoint.Address.ToString());
|
|
|
|
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), paddedPlayerFrame.RectTransform),
|
|
TextManager.Get("Rank"));
|
|
var rankDropDown = new GUIDropDown(new RectTransform(new Vector2(1.0f, 0.1f), paddedPlayerFrame.RectTransform),
|
|
TextManager.Get("Rank"))
|
|
{
|
|
UserData = selectedClient
|
|
};
|
|
foreach (PermissionPreset permissionPreset in PermissionPreset.List)
|
|
{
|
|
rankDropDown.AddItem(permissionPreset.Name, permissionPreset, permissionPreset.Description);
|
|
}
|
|
rankDropDown.AddItem(TextManager.Get("CustomRank"), null);
|
|
|
|
PermissionPreset currentPreset = PermissionPreset.List.Find(p =>
|
|
p.Permissions == selectedClient.Permissions &&
|
|
p.PermittedCommands.Count == selectedClient.PermittedConsoleCommands.Count && !p.PermittedCommands.Except(selectedClient.PermittedConsoleCommands).Any());
|
|
rankDropDown.SelectItem(currentPreset);
|
|
|
|
rankDropDown.OnSelected += (c, userdata) =>
|
|
{
|
|
PermissionPreset selectedPreset = (PermissionPreset)userdata;
|
|
if (selectedPreset != null)
|
|
{
|
|
var client = playerFrame.UserData as Client;
|
|
client.SetPermissions(selectedPreset.Permissions, selectedPreset.PermittedCommands);
|
|
GameMain.Server.UpdateClientPermissions(client);
|
|
|
|
playerFrame = null;
|
|
SelectPlayer(null, client.Name);
|
|
}
|
|
return true;
|
|
};
|
|
|
|
var permissionLabels = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.05f), paddedPlayerFrame.RectTransform), isHorizontal: true)
|
|
{
|
|
Stretch = true,
|
|
RelativeSpacing = 0.05f
|
|
};
|
|
new GUITextBlock(new RectTransform(new Vector2(0.5f, 1.0f), permissionLabels.RectTransform), TextManager.Get("Permissions"));
|
|
new GUITextBlock(new RectTransform(new Vector2(0.5f, 1.0f), permissionLabels.RectTransform), TextManager.Get("PermittedConsoleCommands"));
|
|
|
|
var permissionContainer = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.4f), paddedPlayerFrame.RectTransform), isHorizontal: true)
|
|
{
|
|
Stretch = true,
|
|
RelativeSpacing = 0.05f
|
|
};
|
|
|
|
var permissionsBox = new GUIListBox(new RectTransform(new Vector2(0.5f, 1.0f), permissionContainer.RectTransform))
|
|
{
|
|
UserData = selectedClient
|
|
};
|
|
|
|
foreach (ClientPermissions permission in Enum.GetValues(typeof(ClientPermissions)))
|
|
{
|
|
if (permission == ClientPermissions.None) continue;
|
|
|
|
var permissionTick = new GUITickBox(new RectTransform(new Vector2(0.15f, 0.15f), permissionsBox.Content.RectTransform),
|
|
TextManager.Get("ClientPermission." + permission), font: GUI.SmallFont)
|
|
{
|
|
UserData = permission,
|
|
Selected = selectedClient.HasPermission(permission),
|
|
|
|
OnSelected = (tickBox) =>
|
|
{
|
|
//reset rank to custom
|
|
rankDropDown.SelectItem(null);
|
|
|
|
var client = playerFrame.UserData as Client;
|
|
if (client == null) return false;
|
|
|
|
var thisPermission = (ClientPermissions)tickBox.UserData;
|
|
|
|
if (tickBox.Selected)
|
|
client.GivePermission(thisPermission);
|
|
else
|
|
client.RemovePermission(thisPermission);
|
|
|
|
GameMain.Server.UpdateClientPermissions(client);
|
|
|
|
return true;
|
|
}
|
|
};
|
|
}
|
|
|
|
var commandList = new GUIListBox(new RectTransform(new Vector2(0.5f, 1.0f), permissionContainer.RectTransform))
|
|
{
|
|
UserData = selectedClient
|
|
};
|
|
foreach (DebugConsole.Command command in DebugConsole.Commands)
|
|
{
|
|
var commandTickBox = new GUITickBox(new RectTransform(new Vector2(0.15f, 0.15f), commandList.Content.RectTransform),
|
|
command.names[0], font: GUI.SmallFont)
|
|
{
|
|
Selected = selectedClient.PermittedConsoleCommands.Contains(command),
|
|
ToolTip = command.help,
|
|
UserData = command
|
|
};
|
|
commandTickBox.OnSelected += (GUITickBox tickBox) =>
|
|
{
|
|
//reset rank to custom
|
|
rankDropDown.SelectItem(null);
|
|
|
|
Client client = playerFrame.UserData as Client;
|
|
DebugConsole.Command selectedCommand = tickBox.UserData as DebugConsole.Command;
|
|
if (client == null) return false;
|
|
|
|
if (!tickBox.Selected)
|
|
{
|
|
client.PermittedConsoleCommands.Remove(selectedCommand);
|
|
}
|
|
else if (!client.PermittedConsoleCommands.Contains(selectedCommand))
|
|
{
|
|
client.PermittedConsoleCommands.Add(selectedCommand);
|
|
}
|
|
|
|
GameMain.Server.UpdateClientPermissions(client);
|
|
return true;
|
|
};
|
|
}
|
|
}
|
|
|
|
var buttonAreaUpper = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.1f), paddedPlayerFrame.RectTransform), isHorizontal: true);
|
|
var buttonAreaLower = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.1f), paddedPlayerFrame.RectTransform), isHorizontal: true);
|
|
|
|
if (GameMain.Server != null || GameMain.Client.HasPermission(ClientPermissions.Ban))
|
|
{
|
|
var banButton = new GUIButton(new RectTransform(new Vector2(0.3f, 1.0f), buttonAreaUpper.RectTransform),
|
|
TextManager.Get("Ban"))
|
|
{
|
|
UserData = obj
|
|
};
|
|
banButton.OnClicked += BanPlayer;
|
|
banButton.OnClicked += ClosePlayerFrame;
|
|
|
|
var rangebanButton = new GUIButton(new RectTransform(new Vector2(0.3f, 1.0f), buttonAreaUpper.RectTransform),
|
|
TextManager.Get("BanRange"))
|
|
{
|
|
UserData = obj
|
|
};
|
|
rangebanButton.OnClicked += BanPlayerRange;
|
|
rangebanButton.OnClicked += ClosePlayerFrame;
|
|
}
|
|
|
|
|
|
if (GameMain.Client != null && GameMain.Client.Voting.AllowVoteKick && selectedClient != null)
|
|
{
|
|
var kickVoteButton = new GUIButton(new RectTransform(new Vector2(0.3f, 1.0f), buttonAreaLower.RectTransform),
|
|
TextManager.Get("VoteToKick"))
|
|
{
|
|
Enabled = !selectedClient.HasKickVoteFromID(GameMain.Client.ID),
|
|
OnClicked = GameMain.Client.VoteForKick,
|
|
UserData = selectedClient
|
|
};
|
|
}
|
|
|
|
if (GameMain.Server != null || GameMain.Client.HasPermission(ClientPermissions.Kick))
|
|
{
|
|
var kickButton = new GUIButton(new RectTransform(new Vector2(0.3f, 1.0f), buttonAreaLower.RectTransform),
|
|
TextManager.Get("Kick"))
|
|
{
|
|
UserData = obj
|
|
};
|
|
kickButton.OnClicked = KickPlayer;
|
|
kickButton.OnClicked += ClosePlayerFrame;
|
|
}
|
|
|
|
var closeButton = new GUIButton(new RectTransform(new Vector2(0.3f, 1.0f), buttonAreaLower.RectTransform, Anchor.BottomRight),
|
|
TextManager.Get("Close"))
|
|
{
|
|
IgnoreLayoutGroups = true,
|
|
OnClicked = ClosePlayerFrame
|
|
};
|
|
|
|
return false;
|
|
}
|
|
|
|
private bool ClosePlayerFrame(GUIButton button, object userData)
|
|
{
|
|
playerFrame = null;
|
|
|
|
return true;
|
|
}
|
|
|
|
public bool KickPlayer(GUIButton button, object userData)
|
|
{
|
|
if (userData == null || GameMain.NetworkMember == null) return false;
|
|
GameMain.NetworkMember.CreateKickReasonPrompt(userData.ToString(), false);
|
|
return false;
|
|
}
|
|
|
|
public bool BanPlayer(GUIButton button, object userData)
|
|
{
|
|
if (userData == null || GameMain.NetworkMember == null) return false;
|
|
GameMain.NetworkMember.CreateKickReasonPrompt(userData.ToString(), true);
|
|
return false;
|
|
}
|
|
|
|
public bool BanPlayerRange(GUIButton button, object userData)
|
|
{
|
|
if (userData == null || GameMain.NetworkMember == null) return false;
|
|
GameMain.NetworkMember.CreateKickReasonPrompt(userData.ToString(), true, true);
|
|
return false;
|
|
}
|
|
|
|
public void ClearPlayers()
|
|
{
|
|
playerList.ClearChildren();
|
|
|
|
if (GameMain.Server != null) lastUpdateID++;
|
|
}
|
|
|
|
public override void AddToGUIUpdateList()
|
|
{
|
|
base.AddToGUIUpdateList();
|
|
|
|
if (campaignContainer.Visible)
|
|
{
|
|
chatFrame.AddToGUIUpdateList();
|
|
playerListFrame.AddToGUIUpdateList();
|
|
}
|
|
|
|
playerFrame?.AddToGUIUpdateList();
|
|
campaignSetupUI?.AddToGUIUpdateList();
|
|
jobInfoFrame?.AddToGUIUpdateList();
|
|
}
|
|
|
|
public List<Submarine> GetSubList()
|
|
{
|
|
List<Submarine> subs = new List<Submarine>();
|
|
foreach (GUIComponent component in subList.Content.Children)
|
|
{
|
|
if (component.UserData is Submarine) subs.Add((Submarine)component.UserData);
|
|
}
|
|
|
|
return subs;
|
|
}
|
|
|
|
public override void Update(double deltaTime)
|
|
{
|
|
base.Update(deltaTime);
|
|
|
|
if (campaignSetupUI != null)
|
|
{
|
|
if (!campaignSetupUI.Visible) campaignSetupUI = null;
|
|
}
|
|
|
|
if (autoRestartTimer != 0.0f && autoRestartBox.Selected)
|
|
{
|
|
autoRestartTimer = Math.Max(autoRestartTimer - (float)deltaTime, 0.0f);
|
|
}
|
|
}
|
|
public override void Draw(double deltaTime, GraphicsDevice graphics, SpriteBatch spriteBatch)
|
|
{
|
|
graphics.Clear(Color.Black);
|
|
|
|
GUI.DrawBackgroundSprite(spriteBatch, backgroundSprite);
|
|
|
|
spriteBatch.Begin(SpriteSortMode.Deferred, rasterizerState: GameMain.ScissorTestEnable);
|
|
if (campaignUI != null)
|
|
{
|
|
campaignUI.MapContainer.DrawAuto(spriteBatch);
|
|
}
|
|
GUI.Draw(Cam, spriteBatch);
|
|
spriteBatch.End();
|
|
}
|
|
|
|
public void NewChatMessage(ChatMessage message)
|
|
{
|
|
float prevSize = chatBox.BarSize;
|
|
|
|
while (chatBox.Content.CountChildren > 20)
|
|
{
|
|
chatBox.RemoveChild(chatBox.Content.Children.First());
|
|
}
|
|
|
|
GUITextBlock msg = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), chatBox.Content.RectTransform),
|
|
text: (message.Type == ChatMessageType.Private ? TextManager.Get("PrivateMessageTag") + " " : "") + message.TextWithSender,
|
|
textColor: message.Color,
|
|
color: ((chatBox.CountChildren % 2) == 0) ? Color.Transparent : Color.Black * 0.1f,
|
|
wrap: true, font: GUI.SmallFont)
|
|
{
|
|
UserData = message,
|
|
CanBeFocused = false,
|
|
};
|
|
|
|
if ((prevSize == 1.0f && chatBox.BarScroll == 0.0f) || (prevSize < 1.0f && chatBox.BarScroll == 1.0f)) chatBox.BarScroll = 1.0f;
|
|
}
|
|
|
|
// TODO: remember the previous head(s), check that the next is unique
|
|
private bool ToggleHead(GUIButton button, object userData)
|
|
{
|
|
if (GameMain.NetworkMember.CharacterInfo == null) return true;
|
|
int dir = (int)userData;
|
|
var info = GameMain.NetworkMember.CharacterInfo;
|
|
info.SetRandomRace();
|
|
info.SetRandomHead();
|
|
info.LoadHeadAttachments();
|
|
info.LoadHeadSprite();
|
|
StoreHead();
|
|
GameMain.Config.Save();
|
|
return true;
|
|
}
|
|
|
|
private bool SwitchGender(GUIButton button, object obj)
|
|
{
|
|
Gender gender = (Gender)obj;
|
|
var info = GameMain.NetworkMember.CharacterInfo;
|
|
info.Gender = gender;
|
|
info.SetRandomHead();
|
|
info.LoadHeadAttachments();
|
|
info.LoadHeadSprite();
|
|
StoreHead();
|
|
GameMain.Config.Save();
|
|
return true;
|
|
}
|
|
|
|
private void StoreHead()
|
|
{
|
|
var info = GameMain.NetworkMember.CharacterInfo;
|
|
var config = GameMain.Config;
|
|
config.CharacterRace = info.Race;
|
|
config.CharacterGender = info.Gender;
|
|
config.CharacterHeadIndex = info.HeadSpriteId;
|
|
config.CharacterHairIndex = info.HairIndex;
|
|
config.CharacterBeardIndex = info.BeardIndex;
|
|
config.CharacterMoustacheIndex = info.MoustacheIndex;
|
|
config.CharacterFaceAttachmentIndex = info.FaceAttachmentIndex;
|
|
}
|
|
|
|
public void SelectMode(int modeIndex)
|
|
{
|
|
if (modeIndex < 0 || modeIndex >= modeList.Content.CountChildren || modeList.SelectedIndex == modeIndex) return;
|
|
|
|
if (((GameModePreset)modeList.Content.GetChild(modeIndex).UserData).Identifier == "multiplayercampaign")
|
|
{
|
|
if (GameMain.Server != null)
|
|
{
|
|
campaignSetupUI = MultiPlayerCampaign.StartCampaignSetup();
|
|
return;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
ToggleCampaignMode(false);
|
|
}
|
|
|
|
modeList.Select(modeIndex, true);
|
|
missionTypeContainer.Visible = SelectedMode != null && SelectedMode.Identifier == "mission";
|
|
}
|
|
|
|
private bool SelectMode(GUIComponent component, object obj)
|
|
{
|
|
if (GameMain.NetworkMember == null || obj == modeList.SelectedData) return false;
|
|
|
|
GameModePreset modePreset = obj as GameModePreset;
|
|
if (modePreset == null) return false;
|
|
|
|
//TODO: don't use the name of the game mode to determine its type
|
|
missionTypeContainer.Visible = modePreset.Identifier == "mission";
|
|
|
|
if (modePreset.Identifier == "multiplayercampaign")
|
|
{
|
|
//campaign selected and the campaign view has not been set up yet
|
|
// -> don't select the mode yet and start campaign setup
|
|
if (GameMain.Server != null && !campaignContainer.Visible)
|
|
{
|
|
campaignSetupUI = MultiPlayerCampaign.StartCampaignSetup();
|
|
return false;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
ToggleCampaignMode(false);
|
|
}
|
|
|
|
lastUpdateID++;
|
|
return true;
|
|
}
|
|
|
|
public void ToggleCampaignView(bool enabled)
|
|
{
|
|
campaignContainer.Visible = enabled;
|
|
defaultModeContainer.Visible = !enabled;
|
|
}
|
|
|
|
public void ToggleCampaignMode(bool enabled)
|
|
{
|
|
ToggleCampaignView(enabled);
|
|
|
|
if (!enabled)
|
|
{
|
|
campaignCharacterInfo = null;
|
|
CampaignCharacterDiscarded = false;
|
|
UpdatePlayerFrame(null);
|
|
}
|
|
|
|
subList.Enabled = !enabled && AllowSubSelection;
|
|
shuttleList.Enabled = !enabled && AllowSubSelection;
|
|
seedBox.Enabled = !enabled && GameMain.Server != null;
|
|
|
|
if (campaignViewButton != null) campaignViewButton.Visible = enabled;
|
|
if (StartButton != null) StartButton.Visible = !enabled && GameMain.Server != null;
|
|
|
|
if (enabled)
|
|
{
|
|
if (campaignUI == null || campaignUI.Campaign != GameMain.GameSession.GameMode)
|
|
{
|
|
campaignContainer.ClearChildren();
|
|
|
|
campaignUI = new CampaignUI(GameMain.GameSession.GameMode as CampaignMode, campaignContainer)
|
|
{
|
|
StartRound = () => { GameMain.Server.StartGame(); }
|
|
};
|
|
campaignUI.MapContainer.RectTransform.NonScaledSize = new Point(GameMain.GraphicsWidth, GameMain.GraphicsHeight);
|
|
|
|
var backButton = new GUIButton(new RectTransform(new Vector2(0.2f, 0.08f), campaignContainer.RectTransform, Anchor.TopCenter) { RelativeOffset = new Vector2(0.0f, 0.02f) },
|
|
TextManager.Get("Back"), style: "GUIButtonLarge");
|
|
backButton.OnClicked += (btn, obj) => { ToggleCampaignView(false); return true; };
|
|
|
|
var restartText = new GUITextBlock(new RectTransform(new Vector2(0.25f, 0.1f), campaignContainer.RectTransform, Anchor.BottomRight), "", font: GUI.SmallFont)
|
|
{
|
|
TextGetter = AutoRestartText
|
|
};
|
|
}
|
|
modeList.Select(2, true);
|
|
}
|
|
else
|
|
{
|
|
campaignUI = null;
|
|
}
|
|
|
|
if (GameMain.Server != null)
|
|
{
|
|
lastUpdateID++;
|
|
}
|
|
}
|
|
|
|
private bool SelectSeed(GUITextBox textBox, string seed)
|
|
{
|
|
if (GameMain.Server == null) return false;
|
|
if (string.IsNullOrWhiteSpace(seed)) return false;
|
|
LevelSeed = seed;
|
|
return true;
|
|
}
|
|
|
|
private bool ViewJobInfo(GUIButton button, object obj)
|
|
{
|
|
JobPrefab jobPrefab = button.UserData as JobPrefab;
|
|
if (jobPrefab == null) return false;
|
|
|
|
jobInfoFrame = jobPrefab.CreateInfoFrame();
|
|
GUIButton closeButton = new GUIButton(new RectTransform(new Vector2(0.25f, 0.05f), jobInfoFrame.GetChild(2).GetChild(0).RectTransform, Anchor.BottomRight),
|
|
TextManager.Get("Close"))
|
|
{
|
|
OnClicked = CloseJobInfo
|
|
};
|
|
jobInfoFrame.OnClicked = (btn, userdata) => { if (GUI.MouseOn == btn || GUI.MouseOn == btn.TextBlock) CloseJobInfo(btn, userdata); return true; };
|
|
|
|
return true;
|
|
}
|
|
|
|
private bool CloseJobInfo(GUIButton button, object obj)
|
|
{
|
|
jobInfoFrame = null;
|
|
return true;
|
|
}
|
|
|
|
private bool ChangeJobPreference(GUIButton button, object obj)
|
|
{
|
|
GUIComponent jobText = button.Parent.Parent;
|
|
|
|
int index = jobList.Content.GetChildIndex(jobText);
|
|
int newIndex = index + (int)obj;
|
|
if (newIndex < 0 || newIndex > jobList.Content.CountChildren - 1) return false;
|
|
|
|
jobText.RectTransform.RepositionChildInHierarchy(newIndex);
|
|
|
|
UpdateJobPreferences(jobList);
|
|
|
|
return true;
|
|
}
|
|
|
|
private void UpdateJobPreferences(GUIListBox listBox)
|
|
{
|
|
listBox.Deselect();
|
|
List<string> jobNamePreferences = new List<string>();
|
|
|
|
for (int i = 0; i < listBox.Content.CountChildren; i++)
|
|
{
|
|
float a = (float)(i - 1) / 3.0f;
|
|
a = Math.Min(a, 3);
|
|
Color color = new Color(1.0f - a, (1.0f - a) * 0.6f, 0.0f, 0.3f);
|
|
|
|
GUIComponent child = listBox.Content.GetChild(i);
|
|
|
|
child.Color = color;
|
|
child.HoverColor = color;
|
|
child.SelectedColor = color;
|
|
|
|
(child.GetChild<GUITextBlock>()).Text = (i + 1) + ". " + (child.UserData as JobPrefab).Name;
|
|
|
|
jobNamePreferences.Add((child.UserData as JobPrefab).Identifier);
|
|
}
|
|
|
|
if (!GameMain.Config.JobPreferences.SequenceEqual(jobNamePreferences))
|
|
{
|
|
GameMain.Config.JobPreferences = jobNamePreferences;
|
|
GameMain.Config.Save();
|
|
}
|
|
}
|
|
|
|
public Pair<string, string> FailedSelectedSub;
|
|
public Pair<string, string> FailedSelectedShuttle;
|
|
|
|
public bool TrySelectSub(string subName, string md5Hash, GUIListBox subList)
|
|
{
|
|
if (GameMain.Client == null) return false;
|
|
|
|
//already downloading the selected sub file
|
|
if (GameMain.Client.FileReceiver.ActiveTransfers.Any(t => t.FileName == subName + ".sub"))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
Submarine sub = Submarine.SavedSubmarines.FirstOrDefault(m => m.Name == subName && m.MD5Hash.Hash == md5Hash);
|
|
if (sub == null) sub = Submarine.SavedSubmarines.FirstOrDefault(m => m.Name == subName);
|
|
|
|
var matchingListSub = subList.Content.GetChildByUserData(sub);
|
|
if (matchingListSub != null)
|
|
{
|
|
if (subList.Parent is GUIDropDown subDropDown)
|
|
{
|
|
subDropDown.SelectItem(sub);
|
|
}
|
|
else
|
|
{
|
|
subList.OnSelected -= VotableClicked;
|
|
subList.Select(subList.Content.GetChildIndex(matchingListSub), true);
|
|
subList.OnSelected += VotableClicked;
|
|
}
|
|
|
|
if (subList == SubList)
|
|
FailedSelectedSub = null;
|
|
else
|
|
FailedSelectedShuttle = null;
|
|
}
|
|
|
|
if (sub == null || sub.MD5Hash.Hash != md5Hash)
|
|
{
|
|
if (subList == SubList)
|
|
FailedSelectedSub = new Pair<string, string>(subName, md5Hash);
|
|
else
|
|
FailedSelectedShuttle = new Pair<string, string>(subName, md5Hash);
|
|
|
|
string errorMsg = "";
|
|
if (sub == null)
|
|
{
|
|
errorMsg = TextManager.Get("SubNotFoundError").Replace("[subname]", subName) + " ";
|
|
}
|
|
else if (sub.MD5Hash.Hash == null)
|
|
{
|
|
errorMsg = TextManager.Get("SubLoadError").Replace("[subname]", subName) + " ";
|
|
if (matchingListSub != null) matchingListSub.GetChild<GUITextBox>().TextColor = Color.Red;
|
|
}
|
|
else
|
|
{
|
|
errorMsg = TextManager.Get("SubDoesntMatchError").Replace("[subname]", sub.Name).Replace("[myhash]", sub.MD5Hash.ShortHash).Replace("[serverhash]", Md5Hash.GetShortHash(md5Hash)) + " ";
|
|
}
|
|
|
|
errorMsg += TextManager.Get("DownloadSubQuestion");
|
|
|
|
//already showing a message about the same sub
|
|
if (GUIMessageBox.MessageBoxes.Any(mb => mb.UserData as string == "request" + subName))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
var requestFileBox = new GUIMessageBox(TextManager.Get("DownloadSubLabel"), errorMsg, new string[] { TextManager.Get("Yes"), TextManager.Get("No") }, 400, 300);
|
|
requestFileBox.UserData = "request" + subName;
|
|
requestFileBox.Buttons[0].UserData = new string[] { subName, md5Hash };
|
|
requestFileBox.Buttons[0].OnClicked += requestFileBox.Close;
|
|
requestFileBox.Buttons[0].OnClicked += (GUIButton button, object userdata) =>
|
|
{
|
|
string[] fileInfo = (string[])userdata;
|
|
GameMain.Client?.RequestFile(FileTransferType.Submarine, fileInfo[0], fileInfo[1]);
|
|
return true;
|
|
};
|
|
requestFileBox.Buttons[1].OnClicked += requestFileBox.Close;
|
|
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
}
|
|
}
|