|
||
|
|||||||
| Script Support Get support for modifying RunUO Scripts, or writing your own! |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 (permalink) |
|
Forum Expert
|
OK, I have been working on a special UI for my players which needs to remember where the player left the gump when it comes to logout and login events.
The X and Y do not seem o update on any specified gumps after they have been dragged to a new position. I have searched the forums and found the same question, but without an answer... Is it possible to retreive the new X and Y position of the Gump in question? I don't want a quick, easy fix or work-around, I want to do this exactly as I need it, but I haven't found the relevant information or documentation taht can help me out with this... So any ideas, anyone? Is there a packet that sends gump positions back to the server, etc?
__________________
![]() RPK.VORSPIRE.COM - The WoW-UO Cross-Over Shard |
|
|
|
|
|
#2 (permalink) |
|
ConnectUO Creator
Join Date: Jan 2004
Location: In your mom
Age: 27
Posts: 4,763
|
not that im aware of
![]()
__________________
Jeff Boulanger ConnectUO - Core Developer Want to help make ConnectUO better? Click here to submit your ideas/requests Use your talent to compete against other community members in RunUO hosted coding competitions If you know XNA (even if its just a little) or are a good artist(2d or 3d) and are interested in making games for a hobby send me a pm or drop by #xna in irc.runuo.com. I'm looking to put together a small game development team. Please do not pm me for support. If you are having issues please post in the appropriate forum. Thanks for your continued support of both ConnectUO and RunUO |
|
|
|
|
|
#5 (permalink) |
|
Forum Expert
|
OK,
I kinda have a way to track the Gumps. Let me break it down, I would like to show you what I intend to use this for... There is the main gump with 3 sub-panels, the main gump is an anchor, known as the "RPKUI" class. The sub panels are known as "Left Panel or Main Panel", "Status Panel or Status Bar Panel" and "Ability Panel". I do not need to post the sub-panel gump scripts, as they are tracked by a heirarchy registry system and are therefore obsolete in regards to this post. This is the Main Gump, RPKUI class; Code:
public class RPKUI : Gump
{
public static int DefaultX { get { return 110; } }
public static int DefaultY { get { return 80; } }
PlayerMobile caller;
//Timer m_Timer;
public static void Initialize()
{
Commands.Register("RPKUI", AccessLevel.Administrator, new CommandEventHandler(RPKUI_OnCommand));
}
[Usage("RPKUI")]
[Description("Starts a new instace of the RPK UI.")]
public static void RPKUI_OnCommand(CommandEventArgs e)
{
PlayerMobile caller = (PlayerMobile)e.Mobile;
caller.NewRPKUI();
}
public RPKUI(PlayerMobile from)
: this(from, 110, 80)
{ }
public RPKUI(PlayerMobile from, int x, int y)
: base(x, y)
{
if (from == null || from.Deleted)
return;
caller = from;
this.Closable = false;
this.Disposable = false;
this.Dragable = false;
this.Resizable = false;
AddPage(0);
//m_Timer = Timer.DelayCall(TimeSpan.FromSeconds(10.0), new TimerCallback(caller.RefreshRPKUI));
//m_Timer.Start();
RPKUICache.Register(caller);
}
public override void OnResponse(NetState sender, RelayInfo info)
{
PlayerMobile from = (PlayerMobile)sender.Mobile;
//switch (info.ButtonID)
//{
//}
}
public void Refresh()
{
RPKUIGumpInfo info = RPKUICache.GetGumpInfo(caller);
int x = info.UI.X, y = info.UI.Y;
if (caller.HasGump(typeof(RPKUI)))
caller.CloseGump(typeof(RPKUI));
caller.SendGump(info.UI);
RPKUICache.Register(caller);
}
public static void Serialize(PlayerMobile parent, GenericWriter writer)
{
writer.Write((int)1);
RPKUIGumpInfo info = RPKUICache.GetGumpInfo(parent);
Console.WriteLine(info.ToString());
if (info != null)
{
writer.Write((bool)info.HasUI);
writer.Write((int)info.UI.X);
writer.Write((int)info.UI.Y);
writer.Write((bool)info.HasLeftPanel);
writer.Write((bool)info.HasStatusPanel);
writer.Write((bool)info.HasAbilityPanel);
writer.Write((int)info.LeftPanelX);
writer.Write((int)info.LeftPanelY);
writer.Write((int)info.StatusPanelX);
writer.Write((int)info.StatusPanelY);
writer.Write((int)info.AbilityPanelX);
writer.Write((int)info.AbilityPanelY);
}
else
{
writer.Write((bool)(parent.RPKUI == null ? false : true));
if (parent.LeftPanel != null)
{
writer.Write((int)parent.RPKUI.X);
writer.Write((int)parent.RPKUI.Y);
}
else
{
writer.Write((int)RPKUI.DefaultX);
writer.Write((int)RPKUI.DefaultY);
}
writer.Write((bool)(parent.LeftPanel == null ? false : true));
writer.Write((bool)(parent.StatusPanel == null ? false : true));
writer.Write((bool)(parent.AbilityPanel == null ? false : true));
if (parent.LeftPanel != null)
{
writer.Write((int)parent.LeftPanel.X);
writer.Write((int)parent.LeftPanel.Y);
}
else
{
writer.Write((int)RPKUI.DefaultX);
writer.Write((int)RPKUI.DefaultY);
}
if (parent.StatusPanel != null)
{
writer.Write((int)parent.StatusPanel.X);
writer.Write((int)parent.StatusPanel.Y);
}
else
{
writer.Write((int)RPKUI.DefaultX);
writer.Write((int)RPKUI.DefaultY);
}
if (parent.LeftPanel != null)
{
writer.Write((int)parent.AbilityPanel.X);
writer.Write((int)parent.AbilityPanel.Y);
}
else
{
writer.Write((int)RPKUI.DefaultX);
writer.Write((int)RPKUI.DefaultY);
}
}
}
public static void Deserialize(PlayerMobile parent, GenericReader reader)
{
int version = reader.ReadInt();
bool rpkUI = true;
bool leftPanel = false;
bool statusPanel = false;
bool abilityPanel = false;
int uiX = DefaultX;
int uiY = DefaultY;
int lpX = DefaultX;
int lpY = DefaultY;
int spX = DefaultX;
int spY = DefaultY;
int apX = DefaultX;
int apY = DefaultY;
switch (version)
{
case 1:
{
rpkUI = reader.ReadBool();
uiX = reader.ReadInt();
uiY = reader.ReadInt();
goto case 0;
}
case 0:
{
leftPanel = reader.ReadBool();
statusPanel = reader.ReadBool();
abilityPanel = reader.ReadBool();
lpX = reader.ReadInt();
lpY = reader.ReadInt();
spX = reader.ReadInt();
spY = reader.ReadInt();
apX = reader.ReadInt();
apY = reader.ReadInt();
if (rpkUI)
parent.RPKUI = new RPKUI(parent, uiX, uiY);
if (leftPanel)
parent.LeftPanel = new RPKUILeftPanel(parent, lpX, lpY);
if (statusPanel)
parent.StatusPanel = new RPKUIStatusBars(parent, spX, spY);
if (abilityPanel)
parent.AbilityPanel = new RPKUIAbilityPanel(parent, apX, apY);
RPKUICache.Register(parent);
break;
}
}
}
}
Code:
public class RPKUICache
{
private static Hashtable m_Registry = new Hashtable();
public static Hashtable Registry { get { return m_Registry; } }
public static int Count { get { return m_Registry.Count; } }
public static RPKUIGumpInfo GetGumpInfo(PlayerMobile parent)
{
if (!m_Registry.ContainsKey(parent))
Register(parent);
return m_Registry[parent] as RPKUIGumpInfo;
}
public static void Register(PlayerMobile parent)
{
if (!m_Registry.ContainsKey(parent))
m_Registry.Add(parent, new RPKUIGumpInfo(parent));
else
m_Registry[parent] = new RPKUIGumpInfo(parent);
}
}
Code:
public class RPKUIGumpInfo
{
private RPKUI rpkUI;
private PlayerMobile mobile;
private bool leftPanel;
private bool statusPanel;
private bool abilityPanel;
private int lpX;
private int lpY;
private int spX;
private int spY;
private int apX;
private int apY;
public RPKUI UI { get { return rpkUI; } }
public PlayerMobile Parent { get { return mobile; } }
public bool HasUI { get { return (rpkUI != null); } }
public bool HasLeftPanel { get { return leftPanel; } }
public bool HasStatusPanel { get { return statusPanel; } }
public bool HasAbilityPanel { get { return abilityPanel; } }
public int LeftPanelX { get { return lpX; } }
public int LeftPanelY { get { return lpY; } }
public int StatusPanelX { get { return spX; } }
public int StatusPanelY { get { return spY; } }
public int AbilityPanelX { get { return apX; } }
public int AbilityPanelY { get { return apY; } }
public RPKUIGumpInfo(PlayerMobile parent)
{
rpkUI = parent.RPKUI;
mobile = parent;
leftPanel = (bool)(parent.LeftPanel == null ? false : true);
statusPanel = (bool)(parent.StatusPanel == null ? false : true);
abilityPanel = (bool)(parent.AbilityPanel == null ? false : true);
if (leftPanel)
{
lpX = (int)parent.LeftPanel.X;
lpY = (int)parent.LeftPanel.Y;
}
else
{
lpX = RPKUI.DefaultX;
lpY = RPKUI.DefaultY;
}
if (statusPanel)
{
spX = (int)parent.StatusPanel.X;
spY = (int)parent.StatusPanel.Y;
}
else
{
spX = RPKUI.DefaultX;
spY = RPKUI.DefaultY;
}
if (abilityPanel)
{
apX = (int)parent.AbilityPanel.X;
apY = (int)parent.AbilityPanel.Y;
}
else
{
apX = RPKUI.DefaultX;
apY = RPKUI.DefaultY;
}
}
public override string ToString()
{
return String.Format("RPKUI Info: {0} - LP:{1} LPX:{2} LPY:{3} - SP:{4} SPX:{5} SPY:{6} - AP:{7} APX:{8} APY:{9} - UI:{10} UIX:{11} UIY:{12}", mobile.Name, leftPanel, lpX, lpY, statusPanel, spX, spY, abilityPanel, apX, apY, rpkUI.ToString(), rpkUI.X, rpkUI.Y);
}
}
For every player on the server, there should be one entry in the Cache. I have managed to put ogether a gump that allows you to move a select panel by an incrment of your choice in any of 8 directions... But i'm still not sure if this is the best way to do thi... If anyone see's anything that can be refined in these scripts, please let me know... Or if you have an opinion on the kind of system I should write to be able to track gump positions, it will be much appreciated. Regards
__________________
![]() RPK.VORSPIRE.COM - The WoW-UO Cross-Over Shard |
|
|
|
![]() |
| Bookmarks |
| Tags |
| drag, gump, gumps, move, position |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|