Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: src/client/cmdusers.cpp
- ===================================================================
- --- src/client/cmdusers.cpp (revision 8452)
- +++ src/client/cmdusers.cpp (working copy)
- @@ -112,6 +112,7 @@
- cmdsource->Subscribe("/roll", this);
- cmdsource->Subscribe("/rotate", this);
- cmdsource->Subscribe("/sell", this);
- + cmdsource->Subscribe("/setwindowpos", this);
- cmdsource->Subscribe("/show", this);
- cmdsource->Subscribe("/sit", this);
- //cmdsource->Subscribe("/spawn", this);
- @@ -138,6 +139,7 @@
- cmdsource->Subscribe("/setoocdesc", this); // set the ooc description of a char
- cmdsource->Subscribe("/loaddesc", this); // load a description for this char from a file
- cmdsource->Subscribe("/loadoocdesc", this); // load a ooc description for this char from a file
- + cmdsource->Subscribe("/togglerun", this); // changes the run status of the character
- }
- psUserCommands::~psUserCommands()
- @@ -190,6 +192,7 @@
- cmdsource->Unsubscribe("/roll", this);
- cmdsource->Unsubscribe("/rotate", this);
- cmdsource->Unsubscribe("/sell", this);
- + cmdsource->Unsubscribe("/setwindowpos", this);
- cmdsource->Unsubscribe("/show", this);
- cmdsource->Unsubscribe("/sit", this);
- //cmdsource->Unsubscribe("/spawn", this);
- @@ -216,6 +219,7 @@
- cmdsource->Unsubscribe("/setoocdesc", this);
- cmdsource->Unsubscribe("/loaddesc", this);
- cmdsource->Unsubscribe("/loadoocdesc", this);
- + cmdsource->Unsubscribe("/togglerun", this);
- @@ -311,7 +315,7 @@
- if ( words[0] == "/show")
- {
- - if (words.GetCount() > 1)
- + if (words.GetCount() == 2)
- {
- pawsControlWindow* ctrlWindow = dynamic_cast<pawsControlWindow*>(PawsManager::GetSingleton().FindWidget("ControlWindow"));
- if(!ctrlWindow || ctrlWindow->HandleWindowName(words[1]))
- @@ -319,8 +323,54 @@
- else return "That window cannot be found.";
- }
- - return "You need to specify a window to show";
- + else if (words.GetCount() == 3)
- + {
- + if (words[2] == "show")
- + {
- + pawsControlWindow* ctrlWindow = dynamic_cast<pawsControlWindow*>(PawsManager::GetSingleton().FindWidget("ControlWindow"));
- + if(!ctrlWindow || ctrlWindow->showWindowName(words[1]))
- + {
- + return NULL;
- + }
- + else
- + {
- + return "That window cannot be found.";
- + }
- + }
- + if (words[2] == "hide")
- + {
- + pawsControlWindow* ctrlWindow = dynamic_cast<pawsControlWindow*>(PawsManager::GetSingleton().FindWidget("ControlWindow"));
- + if(!ctrlWindow || ctrlWindow->hideWindowName(words[1]))
- + {
- + return NULL;
- + }
- + else
- + {
- + return "That window cannot be found.";
- + }
- + }
- + }
- + return "Usage: /show [windowname] [hide|show]";
- }
- + else if ( words[0] == "/setwindowpos" )
- + {
- + if (words.GetCount() == 4)
- + {
- + if ((isdigit(words[2].GetAt(0))) && (isdigit(words[3].GetAt(0))))
- + {
- + pawsControlWindow* ctrlWindow = dynamic_cast<pawsControlWindow*>(PawsManager::GetSingleton().FindWidget("ControlWindow"));
- + if(!ctrlWindow || ctrlWindow->setWindowPositionName(words[1], atoi(words[2]), atoi(words[3])))
- + {
- + return NULL;
- + }
- + else
- + {
- + return "That window cannot be found.";
- + }
- + }
- + }
- + return "Usage: /setwindowpos [windowname] [x] [y]";
- + }
- else if ( words[0] == "/study" )
- {
- pawsWidget * widget = PawsManager::GetSingleton().FindWidget("CraftWindow");
- @@ -1121,6 +1171,41 @@
- }
- }
- + else if (words[0] == "/togglerun")
- + {
- + if ((psengine) && (psengine->GetCharControl()) && (psengine->GetCharControl()->GetMovementManager()))
- + {
- + if (words.GetCount() < 2)
- + {
- + // No parameter so just toggle the current running status of the character
- + psengine->GetCharControl()->GetMovementManager()->ToggleRun();
- + return "Run mode toggled";
- + }
- + else if (words.GetCount() == 2)
- + {
- + // Oh...we have one parameter. Lets see if it's a valid one...and then act accordingly
- + if (words[1] == "run")
- + {
- + // So we should run now? Fine master...whatever you want
- + psengine->GetCharControl()->GetMovementManager()->setRun(true);
- + return "Run mode enabled";
- + }
- + else if (words[1] == "walk")
- + {
- + // time for some relaxing walking for a change
- + psengine->GetCharControl()->GetMovementManager()->setRun(false);
- + return "Run mode disabled";
- + }
- + }
- + // well...if we didn't return yet the syntax was invalid so lets give a hint about the correct usage
- + return "Usage: /togglerun [run/walk]";
- + }
- + else
- + {
- + // if this ever happens a useful error-message is the least of our worries
- + return "Something went really wrong. Couldn't find a valid movement manager...how do you play this game at the moment at all?";
- + }
- + }
- else
- {
- psUserCmdMessage cmdmsg(cmd);
- Index: src/client/gui/pawscontrolwindow.h
- ===================================================================
- --- src/client/gui/pawscontrolwindow.h (revision 8452)
- +++ src/client/gui/pawscontrolwindow.h (working copy)
- @@ -85,6 +85,39 @@
- * @return TRUE if the toggle was possible, returns FALSE if it was not found.
- */
- bool HandleWindowName(csString widgetStr);
- +
- + /** Used to show a window.
- + * If the window was already shown nothing happens.
- + * @param widgetStr: The window to show
- + * @return FALSE in case of an error otherwise TRUE
- + */
- + bool showWindow(csString widgetStr);
- + /** Used to hide a window.
- + * If the window was already hidden nothing happens.
- + * @param widgetStr: The window to show
- + * @return FALSE in case of an error otherwise TRUE
- + */
- + bool hideWindow(csString widgetStr);
- + /** Used to show a window from a command.
- + * If the window was already shown nothing happens.
- + * @param widgetStr: The window to hide (command form, translated to the actual window name by the function)
- + * @return FALSE in case of an error otherwise TRUE
- + */
- + bool showWindowName(csString widgetStr);
- + /** Used to hide a window from a command.
- + * If the window was already hidden nothing happens.
- + * @param widgetStr: The window to hide (command form, translated to the actual window name by the function)
- + * @return FALSE in case of an error otherwise TRUE
- + */
- + bool hideWindowName(csString widgetStr);
- +
- + /** Used to set the position of windows from a command.
- + * @param widgetStr: The window to hide (command form, translated to the actual window name by the function)
- + * @param x: New x postion ofthe window
- + * @param y: New y postion ofthe window
- + * @return FALSE in case of an error otherwise TRUE
- + */
- + bool setWindowPositionName(csString widgetStr, int x, int y);
- /** When the quit button is pressed this method displays the yes/no dialog
- * box to confirm that a user really wants to quit.
- @@ -146,6 +179,15 @@
- bool Contains( int x, int y );
- private:
- + /** helper function for commands to translate to widget names from a more readable form
- + * This is copied from a previous version so don't blame me for it. I think it's very badly done
- + * and it contains hardcoded widget names. So if anyone needs to add a new window to PS this function
- + * must be altered. The "correct" way would be probably to put these translations in an xml file that comes
- + * with the gui...but can't be bothered to write that.
- + * @param widgetStr: The widget name to be translated
- + * @return The actual widget name used by the system or an empty string if this widget is unkown to this function
- + */
- + csString translateWidgetName(csString widgetStr);
- unsigned short int style;
- bool hidden;
- csArray<WBName> wbs;
- Index: src/client/gui/pawscontrolwindow.cpp
- ===================================================================
- --- src/client/gui/pawscontrolwindow.cpp (revision 8452)
- +++ src/client/gui/pawscontrolwindow.cpp (working copy)
- @@ -295,86 +295,279 @@
- bool pawsControlWindow::HandleWindowName(csString widgetStr)
- {
- - csString widget;
- + csString widget = translateWidgetName(widgetStr);
- +
- + if(widget == "quit")
- + {
- + HandleQuit();
- + return true;
- + }
- + if(widget == "buy")
- + {
- + psengine->GetCmdHandler()->Execute("/buy");
- + return true;
- + }
- + if(widget != "")
- + {
- + HandleWindow(widget);
- + return true;
- + }
- + else return false;
- +}
- +
- +bool pawsControlWindow::showWindow(csString widgetStr)
- +{
- + // lets see if we can find the specified window
- + pawsWidget* widget = PawsManager::GetSingleton().FindWidget(widgetStr.GetData());
- + if (!widget)
- + {
- + // doesn't look like it, log and return with an error
- + Error2("%s isn't loaded", widgetStr.GetData());
- + return false;
- + }
- + // if the window was not visible before we show it now.
- + if ( !widget->IsVisible() )
- + {
- + widget->Show();
- + }
- + return true;
- +}
- +
- +bool pawsControlWindow::hideWindow(csString widgetStr)
- +{
- + // lets see if we can find the specified window
- + pawsWidget* widget = PawsManager::GetSingleton().FindWidget(widgetStr.GetData());
- + if (!widget)
- + {
- + // doesn't look like it, log and return with an error
- + Error2("%s isn't loaded", widgetStr.GetData());
- + return false;
- + }
- + // if the window was not visible before we show it now.
- + if ( widget->IsVisible() )
- + {
- + widget->Hide();
- + // Don't leave focus on us after hiding
- + if ( this->Includes(PawsManager::GetSingleton().GetCurrentFocusedWidget()) )
- + {
- + PawsManager::GetSingleton().SetCurrentFocusedWidget(NULL);
- + }
- + }
- + return true;
- +}
- +
- +bool pawsControlWindow::showWindowName(csString widgetStr)
- +{
- + csString widget = translateWidgetName(widgetStr);
- +
- + // special handling for a few widgets
- + if(widget == "quit")
- + {
- + HandleQuit();
- + return true;
- + }
- + if(widget == "buy")
- + {
- + psengine->GetCmdHandler()->Execute("/buy");
- + return true;
- + }
- + // otherwise just show the window
- + if(widget != "")
- + {
- + return showWindow(widget);
- + }
- + else return false;
- +}
- +
- +bool pawsControlWindow::hideWindowName(csString widgetStr)
- +{
- + csString widget = translateWidgetName(widgetStr);
- +
- + // special handling for a few widgets
- + if(widget == "quit")
- + {
- + // actually we don't do anything here...makes no sense to hide the quit dialog
- + return true;
- + }
- + if(widget == "buy")
- + {
- + // we don't do anything here either...might be changed at some point.
- + return true;
- + }
- + // otherwise just hide the window
- + if(widget != "")
- + {
- + return hideWindow(widget);
- + }
- + else return false;
- +}
- +
- +bool pawsControlWindow::setWindowPositionName(csString widgetStr, int x, int y)
- +{
- + csString widget = translateWidgetName(widgetStr);
- +
- + // special handling for a few widgets
- + if(widget == "quit")
- + {
- + // actually we don't do anything here...always in the middle of the screen
- + return true;
- + }
- + if(widget == "buy")
- + {
- + // we don't do anything here either...might be changed at some point.
- + return true;
- + }
- + // otherwise set the new position of the window
- + if(widget != "")
- + {
- + pawsWidget* w = PawsManager::GetSingleton().FindWidget(widget.GetData());
- + if (!w)
- + {
- + Error2("%s isn't loaded", widget.GetData());
- + return false;
- + }
- + w->SetRelativeFramePos(x,y);
- + return true;
- + }
- + return false;
- +}
- +
- +csString pawsControlWindow::translateWidgetName(csString widgetStr)
- +{
- + csString widget = "";
- widgetStr.Downcase();
- if(widgetStr == "options" )
- + {
- widget = "ConfigWindow";
- + }
- else if(widgetStr == "stats" || widgetStr =="skills")
- + {
- widget = "SkillWindow";
- + }
- else if(widgetStr == "spell book" || widgetStr == "spells")
- + {
- widget = "SpellBookWindow";
- + }
- else if(widgetStr == "inventory" || widgetStr == "inv")
- + {
- widget = "InventoryWindow";
- + }
- else if(widgetStr == "help")
- + {
- widget = "HelpWindow";
- + }
- else if(widgetStr == "buddy")
- + {
- widget = "BuddyWindow";
- + }
- else if(widgetStr == "info")
- + {
- widget = "InfoWindow";
- + }
- else if(widgetStr == "petition" || widgetStr == "petitions")
- + {
- widget = "PetitionWindow";
- + }
- else if(widgetStr == "quest")
- + {
- widget = "QuestNotebook";
- + }
- else if(widgetStr == "gm")
- + {
- widget = "GmGUI";
- + }
- else if(widgetStr == "shortcut")
- + {
- widget = "ShortcutWindow";
- + }
- else if(widgetStr == "group")
- + {
- widget = "GroupWindow";
- + }
- else if(widgetStr == "guild")
- + {
- widget = "GuildWindow";
- + }
- else if(widgetStr == "glyph")
- + {
- widget = "GlyphWindow";
- + }
- else if(widgetStr == "sketch")
- + {
- widget = "SketchWindow";
- + }
- else if(widgetStr == "merchant")
- + {
- widget = "MerchantWindow";
- + }
- else if(widgetStr == "loot")
- + {
- widget = "LootWindow";
- + }
- else if(widgetStr == "detail")
- + {
- widget = "DetailWindow";
- + }
- else if(widgetStr == "exchange")
- + {
- widget = "ExchangeWindow";
- + }
- else if(widgetStr == "write")
- + {
- widget = "WritingWindow";
- + }
- else if(widgetStr == "read")
- + {
- widget = "BookReadingWindow";
- + }
- else if(widgetStr == "questreward")
- + {
- widget = "QuestRewardWindow";
- + }
- else if(widgetStr == "craft")
- + {
- widget = "CraftWindow";
- + }
- else if(widgetStr == "ignore")
- + {
- widget = "IgnoreWindow";
- + }
- else if(widgetStr == "bag" || widgetStr == "smallinventory")
- + {
- widget = "SmallInventoryWindow";
- + }
- else if(widgetStr == "talk" || widgetStr == "chat" || widgetStr == "communications")
- + {
- widget = "ChatWindow";
- + }
- else if(widgetStr == "activemagic")
- + {
- widget = "ActiveMagicWindow";
- + }
- else if(widgetStr == "managepetitions")
- + {
- widget = "PetitionGMWindow";
- + }
- else if(widgetStr == "quickspell")
- + {
- widget = "HotBar";
- + }
- else if(widgetStr == "music")
- + {
- widget = "MusicWindow";
- + }
- else if(widgetStr == "quit")
- {
- - HandleQuit();
- - return true;
- + widget = "quit";
- }
- else if(widgetStr == "buy")
- {
- - psengine->GetCmdHandler()->Execute("/buy");
- - return true;
- + widget = "buy";
- }
- - if(widget)
- - {
- - HandleWindow(widget);
- - return true;
- - }
- - else return false;
- + return widget;
- }
- +
- void pawsControlWindow::HandleQuit()
- {
- PawsManager::GetSingleton().CreateYesNoBox( "\nDo you really wish to leave Yliakum?", this );
- Index: src/client/psmovement.h
- ===================================================================
- --- src/client/psmovement.h (revision 8452)
- +++ src/client/psmovement.h (working copy)
- @@ -194,6 +194,11 @@
- void ToggleAutoMove();
- void ToggleRun();
- + /**
- + * Changes the run state of the actor
- + * @param runState true sets the actor to running mode while false makes the actor walk
- + */
- + void setRun(bool runState);
- void SetSneaking(bool v) { sneaking = v; }
- bool Sneaking() { return sneaking; }
- Index: src/client/psmovement.cpp
- ===================================================================
- --- src/client/psmovement.cpp (revision 8452)
- +++ src/client/psmovement.cpp (working copy)
- @@ -1000,3 +1000,19 @@
- toggleRun = true;
- }
- }
- +
- +void psMovementManager::setRun(bool runState)
- +{
- + if (runState)
- + {
- + defaultmode = run;
- + Start(run);
- + toggleRun = true;
- + }
- + else
- + {
- + defaultmode = walk;
- + Stop(run);
- + toggleRun = false;
- + }
- +}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement