mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-08 14:48:47 -04:00
Notify icon doesn't autofocus when clicked and shows player count, first work on getting /undoplayer to work with console
This commit is contained in:
parent
a7b3d9e2c8
commit
efeff445d7
6
GUI/Window/Window.Designer.cs
generated
6
GUI/Window/Window.Designer.cs
generated
@ -369,21 +369,21 @@ namespace MCGalaxy.Gui
|
||||
//
|
||||
this.icon_openConsole.Name = "icon_openConsole";
|
||||
this.icon_openConsole.Size = new System.Drawing.Size(157, 22);
|
||||
this.icon_openConsole.Text = "Open Console";
|
||||
this.icon_openConsole.Text = "Open console";
|
||||
this.icon_openConsole.Click += new System.EventHandler(this.openConsole_Click);
|
||||
//
|
||||
// icon_shutdown
|
||||
//
|
||||
this.icon_shutdown.Name = "icon_shutdown";
|
||||
this.icon_shutdown.Size = new System.Drawing.Size(157, 22);
|
||||
this.icon_shutdown.Text = "Shutdown Server";
|
||||
this.icon_shutdown.Text = "Shutdown server";
|
||||
this.icon_shutdown.Click += new System.EventHandler(this.shutdownServer_Click);
|
||||
//
|
||||
// icon_restart
|
||||
//
|
||||
this.icon_restart.Name = "icon_restart";
|
||||
this.icon_restart.Size = new System.Drawing.Size(157, 22);
|
||||
this.icon_restart.Text = "Restart Server";
|
||||
this.icon_restart.Text = "Restart server";
|
||||
this.icon_restart.Click += new System.EventHandler(this.icon_restart_Click);
|
||||
//
|
||||
// main_btnProps
|
||||
|
@ -22,10 +22,12 @@ namespace MCGalaxy.Gui {
|
||||
public partial class Window : Form {
|
||||
PlayerProperties playerProps;
|
||||
|
||||
public void UpdatePlayersListBox() {
|
||||
void UpdatePlayers() {
|
||||
RunOnUiThread(
|
||||
delegate {
|
||||
pl_listBox.Items.Clear();
|
||||
UpdateNotifyIconText();
|
||||
|
||||
Player[] players = PlayerInfo.Online.Items;
|
||||
foreach (Player p in players)
|
||||
pl_listBox.Items.Add(p.name);
|
||||
|
@ -74,12 +74,17 @@ namespace MCGalaxy.Gui {
|
||||
|
||||
}
|
||||
|
||||
void MakeNotifyIcon() {
|
||||
notifyIcon.Text = Server.name.Truncate(63);
|
||||
void UpdateNotifyIconText() {
|
||||
int playerCount = PlayerInfo.Online.Count;
|
||||
string players = " (" + playerCount + " players)";
|
||||
notifyIcon.Text = (Server.name + players).Truncate(63);
|
||||
}
|
||||
|
||||
void MakeNotifyIcon() {
|
||||
UpdateNotifyIconText();
|
||||
notifyIcon.ContextMenuStrip = this.icon_context;
|
||||
notifyIcon.Icon = this.Icon;
|
||||
notifyIcon.Visible = true;
|
||||
notifyIcon.MouseClick += new System.Windows.Forms.MouseEventHandler(notifyIcon1_MouseClick);
|
||||
}
|
||||
|
||||
void InitServer() {
|
||||
@ -114,11 +119,11 @@ namespace MCGalaxy.Gui {
|
||||
public void RunOnUiThread(Action act) { Invoke(act); }
|
||||
|
||||
void Player_PlayerConnect(Player p) {
|
||||
UpdatePlayersListBox();
|
||||
UpdatePlayers();
|
||||
}
|
||||
|
||||
void Player_PlayerDisconnect(Player p, string reason) {
|
||||
UpdatePlayersListBox();
|
||||
UpdatePlayers();
|
||||
}
|
||||
|
||||
void Player_OnSendMap(Player p, byte[] buffer) {
|
||||
@ -149,7 +154,7 @@ namespace MCGalaxy.Gui {
|
||||
Invoke(new VoidDelegate(SettingsUpdate));
|
||||
} else {
|
||||
Text = Server.name + " - " + Server.SoftwareNameVersioned;
|
||||
notifyIcon.Text = Server.name.Truncate(63);
|
||||
UpdateNotifyIconText();
|
||||
}
|
||||
}
|
||||
|
||||
@ -193,6 +198,7 @@ namespace MCGalaxy.Gui {
|
||||
Invoke(new PlayerListCallback(UpdateClientList), playerList); return;
|
||||
}
|
||||
|
||||
UpdateNotifyIconText();
|
||||
if (main_Players.DataSource == null)
|
||||
main_Players.DataSource = pc;
|
||||
|
||||
@ -303,7 +309,7 @@ namespace MCGalaxy.Gui {
|
||||
MCGalaxy.Gui.App.ExitProgram(false);
|
||||
notifyIcon.Dispose();
|
||||
}
|
||||
|
||||
|
||||
if (Server.shuttingDown || MessageBox.Show("Really shutdown the server? All players will be disconnected!", "Exit", MessageBoxButtons.OKCancel) == DialogResult.OK) {
|
||||
if (!Server.shuttingDown) MCGalaxy.Gui.App.ExitProgram(false);
|
||||
notifyIcon.Dispose();
|
||||
@ -328,12 +334,6 @@ namespace MCGalaxy.Gui {
|
||||
ShowInTaskbar = WindowState != FormWindowState.Minimized;
|
||||
}
|
||||
|
||||
void notifyIcon1_MouseClick(object sender, MouseEventArgs e) {
|
||||
Show();
|
||||
BringToFront();
|
||||
WindowState = FormWindowState.Normal;
|
||||
}
|
||||
|
||||
void openConsole_Click(object sender, EventArgs e) {
|
||||
Show();
|
||||
BringToFront();
|
||||
@ -347,7 +347,7 @@ namespace MCGalaxy.Gui {
|
||||
void tabs_Click(object sender, EventArgs e) {
|
||||
try { UpdateUnloadedList(); }
|
||||
catch { }
|
||||
try { UpdatePlayersListBox(); }
|
||||
try { UpdatePlayers(); }
|
||||
catch { }
|
||||
|
||||
try {
|
||||
|
@ -29,7 +29,6 @@ namespace MCGalaxy.Commands.Moderation {
|
||||
public override string type { get { return CommandTypes.Moderation; } }
|
||||
public override bool museumUsable { get { return true; } }
|
||||
public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }
|
||||
public override bool SuperUseable { get { return false; } } // TODO: fix this to work from IRC and Console
|
||||
public override CommandAlias[] Aliases {
|
||||
get { return new[] { new CommandAlias("xundo", null, "all"),
|
||||
new CommandAlias("undoarea", "area"), new CommandAlias("ua", "area") }; }
|
||||
|
@ -101,9 +101,9 @@ namespace MCGalaxy.Undo {
|
||||
|
||||
/// <summary> Arguments provided to an UndoFormat for retrieving undo data. </summary>
|
||||
public class UndoFormatArgs {
|
||||
|
||||
/// <summary> Player associated with this undo, can be console or IRC. </summary>
|
||||
internal readonly Player Player;
|
||||
|
||||
/// <summary> Level to retrieve undo data on. </summary>
|
||||
internal readonly string LevelName;
|
||||
|
||||
/// <summary> Small work buffer, used to avoid memory allocations. </summary>
|
||||
internal byte[] Temp;
|
||||
@ -115,15 +115,13 @@ namespace MCGalaxy.Undo {
|
||||
/// <summary> First instance in time that undo data should be retrieved back to. </summary>
|
||||
internal readonly DateTime Start;
|
||||
|
||||
public UndoFormatArgs(Player p, DateTime start) {
|
||||
Player = p; Start = start;
|
||||
public UndoFormatArgs(string lvlName, DateTime start) {
|
||||
LevelName = lvlName; Start = start;
|
||||
}
|
||||
}
|
||||
|
||||
public struct UndoFormatEntry {
|
||||
public string LevelName;
|
||||
public DateTime Time;
|
||||
|
||||
public DateTime Time;
|
||||
public ushort X, Y, Z;
|
||||
public ExtBlock Block;
|
||||
public ExtBlock NewBlock;
|
||||
|
@ -31,7 +31,6 @@ namespace MCGalaxy.Undo {
|
||||
public override IEnumerable<UndoFormatEntry> GetEntries(Stream s, UndoFormatArgs args) {
|
||||
List<ChunkHeader> list = new List<ChunkHeader>();
|
||||
UndoFormatEntry pos;
|
||||
bool super = Player.IsSuper(args.Player);
|
||||
DateTime start = args.Start;
|
||||
|
||||
ReadHeaders(list, s);
|
||||
@ -40,8 +39,7 @@ namespace MCGalaxy.Undo {
|
||||
// Can we safely discard the entire chunk?
|
||||
bool inRange = chunk.BaseTime.AddTicks(65536 * TimeSpan.TicksPerSecond) >= start;
|
||||
if (!inRange) { args.Stop = true; yield break; }
|
||||
if (!super && !args.Player.level.name.CaselessEq(chunk.LevelName)) continue;
|
||||
pos.LevelName = chunk.LevelName;
|
||||
if (!args.LevelName.CaselessEq(chunk.LevelName)) continue;
|
||||
|
||||
s.Seek(chunk.DataPosition, SeekOrigin.Begin);
|
||||
if (args.Temp == null)
|
||||
|
@ -31,7 +31,6 @@ namespace MCGalaxy.Undo {
|
||||
public override IEnumerable<UndoFormatEntry> GetEntries(Stream s, UndoFormatArgs args) {
|
||||
List<ChunkHeader> list = new List<ChunkHeader>();
|
||||
UndoFormatEntry pos;
|
||||
bool super = Player.IsSuper(args.Player);
|
||||
DateTime start = args.Start;
|
||||
|
||||
ReadHeaders(list, s);
|
||||
@ -40,8 +39,7 @@ namespace MCGalaxy.Undo {
|
||||
// Can we safely discard the entire chunk?
|
||||
bool inRange = chunk.BaseTime.AddTicks((65536 >> 2) * TimeSpan.TicksPerSecond) >= start;
|
||||
if (!inRange) { args.Stop = true; yield break; }
|
||||
if (!super && !args.Player.level.name.CaselessEq(chunk.LevelName)) continue;
|
||||
pos.LevelName = chunk.LevelName;
|
||||
if (!args.LevelName.CaselessEq(chunk.LevelName)) continue;
|
||||
|
||||
s.Seek(chunk.DataPosition, SeekOrigin.Begin);
|
||||
if (args.Temp == null)
|
||||
|
@ -30,8 +30,6 @@ namespace MCGalaxy.Undo {
|
||||
public override IEnumerable<UndoFormatEntry> GetEntries(Stream s, UndoFormatArgs args) {
|
||||
UndoFormatEntry pos = default(UndoFormatEntry);
|
||||
string[] lines = new StreamReader(s).ReadToEnd().SplitSpaces();
|
||||
Player p = args.Player;
|
||||
bool super = Player.IsSuper(p);
|
||||
DateTime start = args.Start;
|
||||
|
||||
// because we have space to end of each entry, need to subtract one otherwise we'll start at a "".
|
||||
@ -43,8 +41,7 @@ namespace MCGalaxy.Undo {
|
||||
if (pos.Time < start) { args.Stop = true; yield break; }
|
||||
|
||||
string map = lines[(i * items) - 7];
|
||||
if (!super && !p.level.name.CaselessEq(map)) continue;
|
||||
pos.LevelName = map;
|
||||
if (!args.LevelName.CaselessEq(map)) continue;
|
||||
|
||||
pos.X = ushort.Parse(lines[(i * items) - 6]);
|
||||
pos.Y = ushort.Parse(lines[(i * items) - 5]);
|
||||
|
@ -67,7 +67,7 @@ namespace MCGalaxy.Drawing.Ops {
|
||||
}
|
||||
}
|
||||
|
||||
UndoFormatArgs args = new UndoFormatArgs(Player, Start);
|
||||
UndoFormatArgs args = new UndoFormatArgs(Level.name, Start);
|
||||
DoOldHighlight(args);
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ namespace MCGalaxy.Drawing.Ops {
|
||||
}
|
||||
}
|
||||
|
||||
UndoFormatArgs args = new UndoFormatArgs(Player, Start);
|
||||
UndoFormatArgs args = new UndoFormatArgs(Level.name, Start);
|
||||
DoOldUndo(args);
|
||||
}
|
||||
|
||||
@ -107,17 +107,13 @@ namespace MCGalaxy.Drawing.Ops {
|
||||
}
|
||||
|
||||
void DoOldUndo(Stream s, UndoFormat format, UndoFormatArgs args) {
|
||||
Level lvl = args.Player == null ? null : args.Player.level;
|
||||
string lastMap = null;
|
||||
DrawOpBlock block;
|
||||
|
||||
DrawOpBlock block;
|
||||
foreach (UndoFormatEntry P in format.GetEntries(s, args)) {
|
||||
if (P.LevelName != lastMap) lvl = LevelInfo.FindExact(P.LevelName);
|
||||
if (lvl == null || P.Time > End) continue;
|
||||
if (P.Time > End) continue;
|
||||
if (P.X < Min.X || P.Y < Min.Y || P.Z < Min.Z) continue;
|
||||
if (P.X > Max.X || P.Y > Max.Y || P.Z > Max.Z) continue;
|
||||
|
||||
byte lvlBlock = lvl.GetTile(P.X, P.Y, P.Z);
|
||||
byte lvlBlock = Level.GetTile(P.X, P.Y, P.Z);
|
||||
if (lvlBlock == P.NewBlock.BlockID || Block.Convert(lvlBlock) == Block.water
|
||||
|| Block.Convert(lvlBlock) == Block.lava || lvlBlock == Block.grass) {
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user