Make all the controls in Window form have logical names, remove 'actions' from the level toolstrip.

This commit is contained in:
UnknownShadow200 2016-08-19 19:00:59 +10:00
parent ea8a42878d
commit 35c4e324b7
3 changed files with 627 additions and 828 deletions

1298
GUI/Window.Designer.cs generated

File diff suppressed because it is too large Load Diff

View File

@ -53,7 +53,7 @@ namespace MCGalaxy.Gui {
InitServer(); InitServer();
notifyIcon1.Text = ("MCGalaxy Server: " + Server.name).Truncate(64); notifyIcon1.Text = ("MCGalaxy Server: " + Server.name).Truncate(64);
notifyIcon1.ContextMenuStrip = this.iconContext; notifyIcon1.ContextMenuStrip = this.icon_context;
notifyIcon1.Icon = this.Icon; notifyIcon1.Icon = this.Icon;
notifyIcon1.Visible = true; notifyIcon1.Visible = true;
notifyIcon1.MouseClick += new System.Windows.Forms.MouseEventHandler(notifyIcon1_MouseClick); notifyIcon1.MouseClick += new System.Windows.Forms.MouseEventHandler(notifyIcon1_MouseClick);
@ -179,40 +179,37 @@ namespace MCGalaxy.Gui {
/// <summary> Updates the list of client names in the window </summary> /// <summary> Updates the list of client names in the window </summary>
/// <param name="players">The list of players to add</param> /// <param name="players">The list of players to add</param>
public void UpdateClientList(List<Player> players) { public void UpdateClientList(List<Player> playerList) {
if (InvokeRequired) { if (InvokeRequired) {
Invoke(new PlayerListCallback(UpdateClientList), players); Invoke(new PlayerListCallback(UpdateClientList), playerList); return;
} else { }
if (main_Players.DataSource == null) if (main_Players.DataSource == null)
main_Players.DataSource = pc; main_Players.DataSource = pc;
// Try to keep the same selection on update // Try to keep the same selection on update
string selected = null; string selected = null;
if (pc.Count > 0 && main_Players.SelectedRows.Count > 0) { var selectedRows = main_Players.SelectedRows;
selected = (from DataGridViewRow row in main_Players.Rows where row.Selected select pc[row.Index]).First().name; if (pc.Count > 0 && selectedRows.Count > 0)
} selected = pc[selectedRows[0].Index].name;
// Update the data source and control // Update the data source and control
//dgvPlayers.SuspendLayout();
pc = new PlayerCollection(); pc = new PlayerCollection();
Player.players.ForEach(p => pc.Add(p)); Player[] players = PlayerInfo.Online.Items;
foreach (Player pl in players)
pc.Add(pl);
//dgvPlayers.Invalidate();
main_Players.DataSource = pc; main_Players.DataSource = pc;
// Reselect player // Reselect player
if (selected != null) if (selected != null) {
{ for (int i = 0; i < main_Players.Rows.Count; i++) {
foreach (Player t in Player.players) if (Equals(main_Players.Rows[i].Cells[0].Value, selected))
for (int j = 0; j < main_Players.Rows.Count; j++) main_Players.Rows[i].Selected = true;
if (Equals(main_Players.Rows[j].Cells[0].Value, selected)) }
main_Players.Rows[j].Selected = true;
} }
main_Players.Refresh(); main_Players.Refresh();
//dgvPlayers.ResumeLayout();
}
} }
public void PopupNotify(string message, ToolTipIcon icon = ToolTipIcon.Info) { public void PopupNotify(string message, ToolTipIcon icon = ToolTipIcon.Info) {
@ -239,19 +236,19 @@ namespace MCGalaxy.Gui {
//dgvPlayers.SuspendLayout(); //dgvPlayers.SuspendLayout();
lc.Clear(); lc.Clear();
string selectedLvl = null; string selectedLvl = null;
if (lbMap_Lded.SelectedItem != null) if (map_lbLoaded.SelectedItem != null)
selectedLvl = lbMap_Lded.SelectedItem.ToString(); selectedLvl = map_lbLoaded.SelectedItem.ToString();
lbMap_Lded.Items.Clear(); map_lbLoaded.Items.Clear();
//lc = new LevelCollection(new LevelListView()); //lc = new LevelCollection(new LevelListView());
Server.levels.ForEach(l => lc.Add(l)); Server.levels.ForEach(l => lc.Add(l));
Server.levels.ForEach(l => lbMap_Lded.Items.Add(l.name)); Server.levels.ForEach(l => map_lbLoaded.Items.Add(l.name));
if (selectedLvl != null) { if (selectedLvl != null) {
int index = lbMap_Lded.Items.IndexOf(selectedLvl); int index = map_lbLoaded.Items.IndexOf(selectedLvl);
lbMap_Lded.SelectedIndex = index; map_lbLoaded.SelectedIndex = index;
} else { } else {
lbMap_Lded.SelectedIndex = -1; map_lbLoaded.SelectedIndex = -1;
} }
UpdateSelectedMap(null, null); UpdateSelectedMap(null, null);
@ -388,11 +385,11 @@ namespace MCGalaxy.Gui {
logs_dateGeneral.Value = DateTime.Now; logs_dateGeneral.Value = DateTime.Now;
} }
catch { } catch { }
foreach (TextBox txtBox in (from TabPage tP in tabControl1.TabPages from Control ctrl in tP.Controls select ctrl).OfType<TextBox>()) foreach (TextBox txtBox in (from TabPage tP in tabs.TabPages from Control ctrl in tP.Controls select ctrl).OfType<TextBox>())
{ {
txtBox.Update(); txtBox.Update();
} }
tabControl1.Update(); tabs.Update();
} }
void restartServerToolStripMenuItem_Click(object sender, EventArgs e) { void restartServerToolStripMenuItem_Click(object sender, EventArgs e) {
@ -517,26 +514,26 @@ namespace MCGalaxy.Gui {
if (mapgen) { MessageBox.Show("A map is already being generated."); return; } if (mapgen) { MessageBox.Show("A map is already being generated."); return; }
string name, x, y, z, type, seed; string name, x, y, z, type, seed;
try { name = txtMap_Name.Text.ToLower(); } try { name = map_txtName.Text.ToLower(); }
catch { name = ""; } catch { name = ""; }
if (String.IsNullOrEmpty(name)) { MessageBox.Show("Map name cannot be blank."); return; } if (String.IsNullOrEmpty(name)) { MessageBox.Show("Map name cannot be blank."); return; }
try { x = cmbMap_X.SelectedItem.ToString(); } try { x = map_cmbX.SelectedItem.ToString(); }
catch { x = ""; } catch { x = ""; }
if (String.IsNullOrEmpty(x)) { MessageBox.Show("Map width cannot be blank."); return; } if (String.IsNullOrEmpty(x)) { MessageBox.Show("Map width cannot be blank."); return; }
try { y = cmbMap_Y.SelectedItem.ToString(); } try { y = map_cmbY.SelectedItem.ToString(); }
catch { y = ""; } catch { y = ""; }
if (String.IsNullOrEmpty(y)) { MessageBox.Show("Map height cannot be blank."); return; } if (String.IsNullOrEmpty(y)) { MessageBox.Show("Map height cannot be blank."); return; }
try { z = cmbMap_Z.SelectedItem.ToString(); } try { z = map_cmbZ.SelectedItem.ToString(); }
catch { z = ""; } catch { z = ""; }
if (String.IsNullOrEmpty(z)) { MessageBox.Show("Map length cannot be blank."); return; } if (String.IsNullOrEmpty(z)) { MessageBox.Show("Map length cannot be blank."); return; }
try { type = cmbMap_Type.SelectedItem.ToString().ToLower(); } try { type = map_cmbType.SelectedItem.ToString().ToLower(); }
catch { type = ""; } catch { type = ""; }
if (String.IsNullOrEmpty(type)) { MessageBox.Show("Map type cannot be blank."); return; } if (String.IsNullOrEmpty(type)) { MessageBox.Show("Map type cannot be blank."); return; }
try { seed = txtMap_Seed.Text; } try { seed = map_txtSeed.Text; }
catch { seed = ""; } catch { seed = ""; }
Thread genThread = new Thread(() => Thread genThread = new Thread(() =>
@ -568,7 +565,7 @@ namespace MCGalaxy.Gui {
void MapLoadClick(object sender, EventArgs e) { void MapLoadClick(object sender, EventArgs e) {
try { try {
Command.all.Find("load").Use(null, lbMap_Unld.SelectedItem.ToString()); Command.all.Find("load").Use(null, map_lbUnloaded.SelectedItem.ToString());
} catch { } catch {
} }
UpdateUnloadedList(); UpdateUnloadedList();
@ -577,47 +574,47 @@ namespace MCGalaxy.Gui {
string last = null; string last = null;
void UpdateSelectedMap(object sender, EventArgs e) { void UpdateSelectedMap(object sender, EventArgs e) {
if (lbMap_Lded.SelectedItem == null) { if (map_lbLoaded.SelectedItem == null) {
if (pgMaps.SelectedObject == null) return; if (map_pgProps.SelectedObject == null) return;
pgMaps.SelectedObject = null; last = null; map_pgProps.SelectedObject = null; last = null;
gbMap_Props.Text = "Properties for (none selected)"; return; map_gbProps.Text = "Properties for (none selected)"; return;
} }
string name = lbMap_Lded.SelectedItem.ToString(); string name = map_lbLoaded.SelectedItem.ToString();
Level lvl = LevelInfo.FindExact(name); Level lvl = LevelInfo.FindExact(name);
if (lvl == null) { if (lvl == null) {
if (pgMaps.SelectedObject == null) return; if (map_pgProps.SelectedObject == null) return;
pgMaps.SelectedObject = null; last = null; map_pgProps.SelectedObject = null; last = null;
gbMap_Props.Text = "Properties for (none selected)"; return; map_gbProps.Text = "Properties for (none selected)"; return;
} }
if (name == last) return; if (name == last) return;
last = name; last = name;
LevelProperties settings = new LevelProperties(lvl); LevelProperties settings = new LevelProperties(lvl);
pgMaps.SelectedObject = settings; map_pgProps.SelectedObject = settings;
gbMap_Props.Text = "Properties for " + name; map_gbProps.Text = "Properties for " + name;
} }
public void UpdateUnloadedList() { public void UpdateUnloadedList() {
RunOnUiThread(() => RunOnUiThread(() =>
{ {
string selectedLvl = null; string selectedLvl = null;
if (lbMap_Unld.SelectedItem != null) if (map_lbUnloaded.SelectedItem != null)
selectedLvl = lbMap_Unld.SelectedItem.ToString(); selectedLvl = map_lbUnloaded.SelectedItem.ToString();
lbMap_Unld.Items.Clear(); map_lbUnloaded.Items.Clear();
string[] files = Directory.GetFiles("levels", "*.lvl"); string[] files = Directory.GetFiles("levels", "*.lvl");
foreach (string file in files) { foreach (string file in files) {
string name = Path.GetFileNameWithoutExtension(file); string name = Path.GetFileNameWithoutExtension(file);
if (LevelInfo.FindExact(name) == null) if (LevelInfo.FindExact(name) == null)
lbMap_Unld.Items.Add(name); map_lbUnloaded.Items.Add(name);
} }
if (selectedLvl != null) { if (selectedLvl != null) {
int index = lbMap_Unld.Items.IndexOf(selectedLvl); int index = map_lbUnloaded.Items.IndexOf(selectedLvl);
lbMap_Unld.SelectedIndex = index; map_lbUnloaded.SelectedIndex = index;
} else { } else {
lbMap_Unld.SelectedIndex = -1; map_lbUnloaded.SelectedIndex = -1;
} }
}); });
} }
@ -660,7 +657,7 @@ namespace MCGalaxy.Gui {
} }
void UpdatePlayerMapCombo() { void UpdatePlayerMapCombo() {
if (tabControl1.SelectedTab != tp_Players) return; if (tabs.SelectedTab != tp_Players) return;
pl_pgProps.Refresh(); pl_pgProps.Refresh();
} }
@ -752,11 +749,6 @@ namespace MCGalaxy.Gui {
} }
#endregion #endregion
void loadOngotoToolStripMenuItem_Click(object sender, EventArgs e) { LevelCmd("map", " loadongoto"); }
void instantBuildingToolStripMenuItem_Click(object sender, EventArgs e) { LevelCmd("map", " instant"); }
void autpPhysicsToolStripMenuItem_Click(object sender, EventArgs e) { LevelCmd("map", " restartphysics"); }
void gunsToolStripMenuItem_Click(object sender, EventArgs e) { LevelCmd("allowguns"); }
void unloadToolStripMenuItem1_Click(object sender, EventArgs e) { LevelCmd("map", " unload"); }
void infoToolStripMenuItem_Click(object sender, EventArgs e) { LevelCmd("map"); LevelCmd("mapinfo"); } void infoToolStripMenuItem_Click(object sender, EventArgs e) { LevelCmd("map"); LevelCmd("mapinfo"); }
void moveAllToolStripMenuItem_Click(object sender, EventArgs e) { LevelCmd("moveall"); } void moveAllToolStripMenuItem_Click(object sender, EventArgs e) { LevelCmd("moveall"); }
void toolStripMenuItem2_Click_1(object sender, EventArgs e) { LevelCmd("physics", " 0"); } void toolStripMenuItem2_Click_1(object sender, EventArgs e) { LevelCmd("physics", " 0"); }
@ -768,9 +760,6 @@ namespace MCGalaxy.Gui {
void saveToolStripMenuItem_Click_1(object sender, EventArgs e) { LevelCmd("save"); } void saveToolStripMenuItem_Click_1(object sender, EventArgs e) { LevelCmd("save"); }
void unloadToolStripMenuItem_Click_1(object sender, EventArgs e) { LevelCmd("unload"); } void unloadToolStripMenuItem_Click_1(object sender, EventArgs e) { LevelCmd("unload"); }
void reloadToolStripMenuItem_Click(object sender, EventArgs e) { LevelCmd("reload"); } void reloadToolStripMenuItem_Click(object sender, EventArgs e) { LevelCmd("reload"); }
void leafDecayToolStripMenuItem_Click(object sender, EventArgs e) { LevelCmd("map", " leafdecay"); }
void randomFlowToolStripMenuItem_Click(object sender, EventArgs e) { LevelCmd("map", " randomflow"); }
void treeGrowingToolStripMenuItem_Click(object sender, EventArgs e) { LevelCmd("map", " growtrees"); }
#region Colored Reader Context Menu #region Colored Reader Context Menu
@ -778,23 +767,23 @@ namespace MCGalaxy.Gui {
if (MessageBox.Show("Changing to and from night mode will clear your logs. Do you still want to change?", "You sure?", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.No) if (MessageBox.Show("Changing to and from night mode will clear your logs. Do you still want to change?", "You sure?", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.No)
return; return;
main_txtLog.NightMode = nightModeToolStripMenuItem.Checked; main_txtLog.NightMode = tsLog_night.Checked;
nightModeToolStripMenuItem.Checked = !nightModeToolStripMenuItem.Checked; tsLog_night.Checked = !tsLog_night.Checked;
} }
void colorsToolStripMenuItem_Click_1(object sender, EventArgs e) { void colorsToolStripMenuItem_Click_1(object sender, EventArgs e) {
main_txtLog.Colorize = !colorsToolStripMenuItem.Checked; main_txtLog.Colorize = !tsLog_Colored.Checked;
colorsToolStripMenuItem.Checked = !colorsToolStripMenuItem.Checked; tsLog_Colored.Checked = !tsLog_Colored.Checked;
} }
void dateStampToolStripMenuItem_Click(object sender, EventArgs e) { void dateStampToolStripMenuItem_Click(object sender, EventArgs e) {
main_txtLog.DateStamp = !dateStampToolStripMenuItem.Checked; main_txtLog.DateStamp = !tsLog_dateStamp.Checked;
dateStampToolStripMenuItem.Checked = !dateStampToolStripMenuItem.Checked; tsLog_dateStamp.Checked = !tsLog_dateStamp.Checked;
} }
void autoScrollToolStripMenuItem_Click(object sender, EventArgs e) { void autoScrollToolStripMenuItem_Click(object sender, EventArgs e) {
main_txtLog.AutoScroll = !autoScrollToolStripMenuItem.Checked; main_txtLog.AutoScroll = !tsLog_autoScroll.Checked;
autoScrollToolStripMenuItem.Checked = !autoScrollToolStripMenuItem.Checked; tsLog_autoScroll.Checked = !tsLog_autoScroll.Checked;
} }
void copySelectedToolStripMenuItem_Click(object sender, EventArgs e) { void copySelectedToolStripMenuItem_Click(object sender, EventArgs e) {