From: <jo...@us...> - 2014-02-05 02:45:20
|
Revision: 9241 http://sourceforge.net/p/planeshift/code/9241 Author: joelyon Date: 2014-02-05 02:45:17 +0000 (Wed, 05 Feb 2014) Log Message: ----------- -Added button sizing and font selection/size/spacing controls to Active Magic configration. -made Shortcut and ActiveMagic config load font options from all .ttfs found in ttf directory (instead of hard coding). Players can now use a custom font for those windows by dropping it in the correct dir and selecting. Modified Paths: -------------- trunk/src/client/gui/pawsactivemagicwindow.cpp trunk/src/client/gui/pawsactivemagicwindow.h trunk/src/client/gui/pawsconfigactivemagic.cpp trunk/src/client/gui/pawsconfigactivemagic.h trunk/src/client/gui/pawsconfigshortcut.cpp trunk/src/client/gui/pawsconfigshortcut.h trunk/src/client/gui/pawsscrollmenu.cpp trunk/src/client/gui/shortcutwindow.cpp trunk/src/common/paws/pawslistbox.cpp trunk/src/common/paws/pawslistbox.h trunk/src/server/gem.cpp trunk/src/server/gem.h Modified: trunk/src/client/gui/pawsactivemagicwindow.cpp =================================================================== --- trunk/src/client/gui/pawsactivemagicwindow.cpp 2014-02-05 00:51:32 UTC (rev 9240) +++ trunk/src/client/gui/pawsactivemagicwindow.cpp 2014-02-05 02:45:17 UTC (rev 9241) @@ -331,7 +331,10 @@ bool pawsActiveMagicWindow::LoadSetting() { csRef<iDocument> doc; - csRef<iDocumentNode> root,mainNode, optionNode; + csRef<iDocumentNode> root, + mainNode, + optionNode, + optionNode2; csString fileName; fileName = "/planeshift/userdata/options/configactivemagic.xml"; @@ -411,6 +414,101 @@ } } + optionNode = mainNode->GetNode("buttonHeight"); + if(optionNode != NULL) + buffList->SetButtonHeight( optionNode->GetAttributeValueAsInt("value", true)); + else + { + Error1("pawsActiveMagicWindow::LoadUserPrefs unable to retrieve buttonHeight node"); + } + + optionNode = mainNode->GetNode("buttonWidthMode"); + if(optionNode != NULL) + { + if( strcasecmp( "buttonWidthAutomatic", optionNode->GetAttributeValue("active") )==0 ) + { + buffList->SetButtonWidth( 0 ); + } + else + { + optionNode = mainNode->GetNode("buttonWidth"); + if(optionNode != NULL) + buffList->SetButtonWidth( optionNode->GetAttributeValueAsInt("value", true)); + else + { + Error1("pawsActiveMagicWindow::LoadUserPrefs unable to retrieve buttonWidth"); + return false; + } + } + } + else + { + Error1("pawsActiveMagicWindow::LoadUserPrefs unable to retrieve buttonWidthMode"); + } + + optionNode = mainNode->GetNode("leftScroll"); + if(optionNode != NULL) + { + if( strcasecmp( "buttonScrollOn", optionNode->GetAttributeValue("active") )==0 ) + buffList->SetLeftScroll( ScrollMenuOptionENABLED ); + else if( strcasecmp( "buttonScrollAuto", optionNode->GetAttributeValue("active") )==0 ) + buffList->SetLeftScroll( ScrollMenuOptionDYNAMIC ); + else if( strcasecmp( "buttonScrollOn", optionNode->GetAttributeValue("active") )==0 ) + buffList->SetLeftScroll( ScrollMenuOptionDISABLED ); + } + else + { + Error1("pawsActiveMagicWindow::LoadUserPrefs unable to retrieve leftScroll node"); + } + + optionNode = mainNode->GetNode("rightScroll"); + if(optionNode != NULL) + { + if( strcasecmp( "buttonScrollOn", optionNode->GetAttributeValue("active") )==0 ) + buffList->SetRightScroll( ScrollMenuOptionENABLED ); + else if( strcasecmp( "buttonScrollAuto", optionNode->GetAttributeValue("active") )==0 ) + buffList->SetRightScroll( ScrollMenuOptionDYNAMIC ); + else if( strcasecmp( "buttonScrollOn", optionNode->GetAttributeValue("active") )==0 ) + buffList->SetRightScroll( ScrollMenuOptionDISABLED ); + } + else + { + Error1("pawsActiveMagicWindow::LoadUserPrefs unable to retrieve rightScroll node"); + } + + optionNode = mainNode->GetNode("textSize"); + if(optionNode == NULL) + { + Error1("pawsActiveMagicWindow::LoadUserPrefs unable to retrieve textSize node"); + } + + optionNode2 = mainNode->GetNode("textFont"); + if(optionNode2 == NULL) + { + Error1("pawsActiveMagicWindow::LoadUserPrefs unable to retrieve textFont node"); + } + + if( optionNode != NULL && optionNode2 != NULL ) + { + fontName = csString( optionNode2->GetAttributeValue("value") ); + + csString fontPath( "/planeshift/data/ttf/"); + fontPath += fontName.GetData(); + fontPath += ".ttf"; + SetFont( fontPath, optionNode->GetAttributeValueAsInt("value", true) ); + buffList->SetFont( fontPath, optionNode->GetAttributeValueAsInt("value", true) ); + } + //else use default. + + optionNode = mainNode->GetNode("textSpacing"); + if(optionNode != NULL) + buffList->SetButtonPaddingWidth( optionNode->GetAttributeValueAsInt("value", true)); + else + { + Error1("pawsActiveMagicWindow::LoadUserPrefs unable to retrieve textSpacing node"); + } + + return true; } @@ -455,3 +553,4 @@ { return show; } + Modified: trunk/src/client/gui/pawsactivemagicwindow.h =================================================================== --- trunk/src/client/gui/pawsactivemagicwindow.h 2014-02-05 00:51:32 UTC (rev 9240) +++ trunk/src/client/gui/pawsactivemagicwindow.h 2014-02-05 02:45:17 UTC (rev 9241) @@ -82,6 +82,15 @@ void SetShowWindow( bool setting ); bool GetShowWindow(); + /** + * return the name of the font + */ + char const * GetFontName() + { + return fontName.GetData(); + } + + private: csRef<iVFS> vfs; Modified: trunk/src/client/gui/pawsconfigactivemagic.cpp =================================================================== --- trunk/src/client/gui/pawsconfigactivemagic.cpp 2014-02-05 00:51:32 UTC (rev 9240) +++ trunk/src/client/gui/pawsconfigactivemagic.cpp 2014-02-05 02:45:17 UTC (rev 9241) @@ -21,6 +21,7 @@ #include <psconfig.h> #include <csutil/xmltiny.h> #include <csutil/objreg.h> +#include <iutil/stringarray.h> #include <iutil/vfs.h> @@ -37,14 +38,26 @@ #include "pawsconfigactivemagic.h" #include "paws/pawsmanager.h" #include "paws/pawscheckbox.h" -#include "shortcutwindow.h" +#include "pawsactivemagicwindow.h" #include "pawsscrollmenu.h" #include "paws/pawsradio.h" + pawsConfigActiveMagic::pawsConfigActiveMagic() : showEffects(NULL), autoResize(NULL), - useImages(NULL) + useImages(NULL), + buttonHeight(NULL), + buttonWidthMode(NULL), + buttonWidth(NULL), + leftScroll(NULL), + rightScroll(NULL), + textFont(NULL), + textSize(NULL), + textSpacing(NULL), + ActiveMagic(NULL), + MenuBar(NULL) + { loaded= false; } @@ -52,12 +65,12 @@ bool pawsConfigActiveMagic::Initialize() { LoadFromFile("configactivemagic.xml"); - //note : if the config files doesn't exist yet it's not an error return true; } bool pawsConfigActiveMagic::PostSetup() { + //get pointer to ActiveMagic window psMainWidget* Main = psengine->GetMainWidget(); if( Main==NULL ) @@ -73,6 +86,14 @@ return false; } + MenuBar = (pawsScrollMenu*)(ActiveMagicWindow->FindWidget( "BuffBar",true )); + if( MenuBar==NULL ) + { + Error1( "pawsConfigShortcut::PostSetup unable to get MenuBar\n"); + return false; + } + + //get form widgets showEffects = (pawsRadioButtonGroup*)FindWidget("showEffects"); if(!showEffects) @@ -98,6 +119,79 @@ return false; } + buttonHeight = (pawsScrollBar*)FindWidget("buttonHeight"); + if(!buttonHeight) + { + return false; + } + buttonHeight->SetMaxValue(64); + buttonHeight->SetCurrentValue(48,false); + + buttonWidthMode = (pawsRadioButtonGroup*)FindWidget("buttonWidthMode"); + if(!buttonWidthMode) + { + return false; + } + + buttonWidth = (pawsScrollBar*)FindWidget("buttonWidth"); + if(!buttonWidth) + { + return false; + } + buttonWidth->SetMaxValue(512); + buttonWidth->SetCurrentValue(48,false); + + leftScroll = (pawsRadioButtonGroup*)FindWidget("leftScroll"); + if(!leftScroll) + { + return false; + } + + rightScroll = (pawsRadioButtonGroup*)FindWidget("rightScroll"); + if(!rightScroll) + { + return false; + } + + textFont = (pawsComboBox*)FindWidget("textFont"); + if(!textFont) + { + return false; + } + csRef<iVFS> vfs = csQueryRegistry<iVFS > ( PawsManager::GetSingleton().GetObjectRegistry()); + if( vfs ) + { + csRef<iStringArray> fileList( vfs->FindFiles( "/planeshift/data/ttf/*.ttf" )); + for (size_t i = 0; i < fileList->GetSize(); i++) + { + csString fileName ( fileList->Get (i)); + fileName.DeleteAt( 0, 21 ); // remove the leading path. + fileName.ReplaceAll( ".ttf", "" ); + + textFont->NewOption( fileName.GetData() ); + } + } + else + { + Error1( "pawsConfigActiveMagic::PostSetup unable to find vfs for font list" ); + } + + textSize = (pawsScrollBar*)FindWidget("textSize"); + if(!textSize) + { + return false; + } + textSize->SetCurrentValue(10,false); + textSize->SetMaxValue(40); + + textSpacing = (pawsScrollBar*)FindWidget("textSpacing"); + if(!textSpacing) + { + return false; + } + textSpacing->SetCurrentValue(4,false); + textSpacing->SetMaxValue(20); + return true; } @@ -108,6 +202,71 @@ showEffects->SetActive( ActiveMagicWindow->GetShowEffects()?"itemAndSpell":"spellOnly" ); showWindow->SetState( ActiveMagicWindow->IsVisible() ); + buttonHeight->SetCurrentValue( MenuBar->GetButtonHeight() ); + if( MenuBar->GetButtonWidth()==0 ) + { + buttonWidthMode->SetActive( "buttonWidthAutomatic" ); + buttonWidth->SetCurrentValue( 0 ); + } + else + { + buttonWidthMode->SetActive( "buttonWidthManual" ); + buttonWidth->SetCurrentValue( MenuBar->GetButtonWidth() ); + } + + textSpacing->SetCurrentValue( MenuBar->GetButtonPaddingWidth() ); + + switch( MenuBar->GetLeftScroll() ) + { + case ScrollMenuOptionENABLED : + { + leftScroll->SetActive( "buttonScrollOn" ); + } + break; + + case ScrollMenuOptionDYNAMIC : + { + leftScroll->SetActive( "buttonScrollAuto" ); + } + break; + + case ScrollMenuOptionDISABLED : + { + leftScroll->SetActive( "buttonScrollOff" ); + } + break; + + } + + switch( MenuBar->GetRightScroll() ) + { + case ScrollMenuOptionENABLED : + { + rightScroll->SetActive( "buttonScrollOn" ); + } + break; + + case ScrollMenuOptionDYNAMIC : + { + rightScroll->SetActive( "buttonScrollAuto" ); + } + break; + + case ScrollMenuOptionDISABLED : + { + rightScroll->SetActive( "buttonScrollOff" ); + } + break; + + } + + textSize->SetCurrentValue(MenuBar->GetFontSize()); + + csString tFontName=csString(((pawsActiveMagicWindow*)ActiveMagicWindow)->GetFontName()); + tFontName.DeleteAt(0,21); + tFontName.ReplaceAll(".ttf","" ); + textFont->Select( tFontName.GetData() ); + loaded= true; dirty = false; @@ -126,7 +285,24 @@ showEffects->GetActive().GetData()); xml.AppendFmt("<showWindow on=\"%s\" />\n", showWindow->GetState() ? "yes" : "no"); + xml.AppendFmt("<buttonHeight value=\"%d\" />\n", + int(buttonHeight->GetCurrentValue())); + xml.AppendFmt("<buttonWidthMode active=\"%s\" />\n", + buttonWidthMode->GetActive().GetData()); + xml.AppendFmt("<buttonWidth value=\"%d\" />\n", + int(buttonWidth->GetCurrentValue())); + xml.AppendFmt("<leftScroll active=\"%s\" />\n", + leftScroll->GetActive().GetData()); + xml.AppendFmt("<rightScroll active=\"%s\" />\n", + rightScroll->GetActive().GetData()); + xml.AppendFmt("<textSize value=\"%d\" />\n", + int(textSize->GetCurrentValue())); + xml.AppendFmt("<textFont value=\"%s\" />\n", + textFont->GetSelectedRowString().GetData()); + xml.AppendFmt("<textSpacing value=\"%d\" />\n", + int(textSpacing->GetCurrentValue())); + xml += "</activemagic>\n"; dirty = false; @@ -142,9 +318,44 @@ bool pawsConfigActiveMagic::OnScroll(int /*scrollDir*/, pawsScrollBar* wdg) { - + if(wdg == buttonWidth && loaded) + { + if(buttonWidth->GetCurrentValue() < buttonHeight->GetCurrentValue()) + buttonWidth->SetCurrentValue(buttonHeight->GetCurrentValue()); + else if( buttonWidth->GetCurrentValue() > buttonWidth->GetMaxValue() ) + buttonWidth->SetCurrentValue(buttonWidth->GetMaxValue()); + + MenuBar->SetButtonWidth( buttonWidth->GetCurrentValue() ); + MenuBar->LayoutButtons(); + + } + else if(wdg == buttonHeight && loaded) + { + if(buttonHeight->GetCurrentValue() < 1) + buttonHeight->SetCurrentValue(1,false); + MenuBar->SetButtonHeight( buttonHeight->GetCurrentValue() ); + MenuBar->LayoutButtons(); + } + else if(wdg == textSize && loaded) + { + if(textSize->GetCurrentValue() < 1) + textSize->SetCurrentValue(1,false); + PickText( textFont->GetSelectedRowString(), textSize->GetCurrentValue() ); + MenuBar->LayoutButtons(); + } + else if(wdg == textSpacing && loaded) + { + if( textSpacing->GetCurrentValue() < 1 ) + textSpacing->SetCurrentValue(1,false); + MenuBar->SetButtonPaddingWidth( textSpacing->GetCurrentValue() ); + MenuBar->LayoutButtons(); + } + if( loaded ) SaveConfig(); + MenuBar->LayoutButtons(); + MenuBar->OnResize(); + ((pawsActiveMagicWindow*)ActiveMagicWindow)->Draw(); return true; } @@ -155,7 +366,7 @@ switch( wdg->GetID() ) { - case 1000 : //spell effects only + case 1020 : //spell effects only { ActiveMagicWindow->SetShowEffects(false); if( ActiveMagicWindow->GetAutoResize() ) @@ -165,7 +376,7 @@ } break; - case 1001 : //Item and spell effects + case 1021 : //Item and spell effects { ActiveMagicWindow->SetShowEffects(true); if( ActiveMagicWindow->GetAutoResize() ) @@ -175,7 +386,7 @@ } break; - case 1002 : // use icons (true) or text (false)? + case 1022 : // use icons (true) or text (false)? { ActiveMagicWindow->SetUseImages(useImages->GetState()); if( ActiveMagicWindow->GetAutoResize() ) @@ -185,7 +396,7 @@ } break; - case 1003 : // auto- or manual sizing + case 1023 : // auto- or manual sizing { ActiveMagicWindow->SetAutoResize(autoResize->GetState()); if( ActiveMagicWindow->GetAutoResize() ) @@ -195,7 +406,7 @@ } break; - case 1004 : // enable or disable the window + case 1024 : // enable or disable the window { ActiveMagicWindow->SetShowWindow(showWindow->GetState()); pawsWidget* widget = PawsManager::GetSingleton().FindWidget( "ActiveMagicWindow" ); @@ -210,6 +421,73 @@ } break; + case 1000 : //buttonWidthMode == automtic + { + MenuBar->SetButtonWidth( 0 ); + } + break; + + case 1001 : //buttonWidthMode == manual + { + MenuBar->SetButtonWidth( buttonWidth->GetCurrentValue() ); + } + break; + + case 1004 : + { + MenuBar->SetLeftScroll(ScrollMenuOptionENABLED ); + ((pawsActiveMagicWindow*)ActiveMagicWindow)->Draw(); + } + break; + + case 1005 : + { + MenuBar->SetLeftScroll(ScrollMenuOptionDYNAMIC ); + ((pawsActiveMagicWindow*)ActiveMagicWindow)->Draw(); + } + break; + + case 1006 : + { + MenuBar->SetLeftScroll(ScrollMenuOptionDISABLED ); + ((pawsActiveMagicWindow*)ActiveMagicWindow)->Draw(); + } + break; + + case 1007 : + { + MenuBar->SetRightScroll(ScrollMenuOptionENABLED ); + ((pawsActiveMagicWindow*)ActiveMagicWindow)->Draw(); + } + break; + + case 1008 : + { + MenuBar->SetRightScroll(ScrollMenuOptionDYNAMIC ); + ((pawsActiveMagicWindow*)ActiveMagicWindow)->Draw(); + } + break; + case 1009 : + { + MenuBar->SetRightScroll(ScrollMenuOptionDISABLED ); + ((pawsActiveMagicWindow*)ActiveMagicWindow)->Draw(); + } + break; + + case 1014 : + { + if( ((pawsCheckBox*)wdg)->GetState()==true ) + { + MenuBar->EnableButtonBackground( true ); + + } + else + { + MenuBar->EnableButtonBackground(false); + } + } + break; + default : { Error2( "pawsConfigActiveMagic::OnButtonPressed got unrecognized widget with ID = %i\n", wdg->GetID() ); @@ -217,18 +495,42 @@ } } - SaveConfig(); + if( loaded ) + { + MenuBar->LayoutButtons(); + MenuBar->OnResize(); + ((pawsActiveMagicWindow*)ActiveMagicWindow)->Draw(); + SaveConfig(); + } return true; } -void pawsConfigActiveMagic::PickText( int index, int size ) +void pawsConfigActiveMagic::PickText( const char * fontName, int size ) { - SaveConfig(); + csString fontPath( "/planeshift/data/ttf/"); + fontPath += fontName; + fontPath += ".ttf"; + SetFont( fontPath, size ); + MenuBar->SetFont( fontPath, size ); + MenuBar->SetButtonFont( fontPath, size ); + + if( loaded ) + { + MenuBar->LayoutButtons(); + MenuBar->OnResize(); + ((pawsActiveMagicWindow*)ActiveMagicWindow)->Draw(); + SaveConfig(); + } + } void pawsConfigActiveMagic::OnListAction(pawsListBox* selected, int status) { + PickText( textFont->GetSelectedRowString(), textSize->GetCurrentValue() ); + MenuBar->LayoutButtons(); + MenuBar->OnResize(); + ((pawsActiveMagicWindow*)ActiveMagicWindow)->Draw(); SaveConfig(); } Modified: trunk/src/client/gui/pawsconfigactivemagic.h =================================================================== --- trunk/src/client/gui/pawsconfigactivemagic.h 2014-02-05 00:51:32 UTC (rev 9240) +++ trunk/src/client/gui/pawsconfigactivemagic.h 2014-02-05 02:45:17 UTC (rev 9241) @@ -24,6 +24,11 @@ #include <csutil/array.h> #include <iutil/document.h> +#include <csutil/csstring.h> +#include <csutil/stringarray.h> +#include <csutil/array.h> + + // PAWS INCLUDES #include "paws/pawswidget.h" #include "paws/pawscombo.h" @@ -39,7 +44,7 @@ class pawsRadioButtonGroup; /* - * class pawsConfigActiveMagic is options screen for configuration of Shortcut Bar + * class pawsConfigActiveMagic is options screen for configuration of Active Magic Bar */ class pawsConfigActiveMagic : public pawsConfigSectionWindow { @@ -60,7 +65,7 @@ virtual bool SaveConfig(); virtual void SetDefault(); - void PickText( int index, int size ); + void PickText( const char * fontName, int size ); void SetMainWindowVisible( bool status ); @@ -74,6 +79,20 @@ pawsCheckBox* useImages; pawsCheckBox* showWindow; + pawsScrollBar* buttonHeight; + pawsRadioButtonGroup* buttonWidthMode; + pawsScrollBar* buttonWidth; + + pawsRadioButtonGroup* leftScroll; + pawsRadioButtonGroup* rightScroll; + + pawsComboBox* textFont; + pawsScrollBar* textSize; + pawsScrollBar* textSpacing; + + pawsWidget* ActiveMagic; + pawsScrollMenu* MenuBar; + bool loaded; }; Modified: trunk/src/client/gui/pawsconfigshortcut.cpp =================================================================== --- trunk/src/client/gui/pawsconfigshortcut.cpp 2014-02-05 00:51:32 UTC (rev 9240) +++ trunk/src/client/gui/pawsconfigshortcut.cpp 2014-02-05 02:45:17 UTC (rev 9241) @@ -21,6 +21,7 @@ #include <psconfig.h> #include <csutil/xmltiny.h> #include <csutil/objreg.h> +#include <iutil/stringarray.h> #include <iutil/vfs.h> @@ -156,14 +157,25 @@ { return false; } - textFont->NewOption( "Liberation Sans" ); - textFont->NewOption( "Liberation Serif" ); - textFont->NewOption( "Liberation Mono" ); - textFont->NewOption( "Sonora" ); - textFont->NewOption( "Cup and Talon" ); - textFont->NewOption( "Scurlock" ); - textFont->NewOption( "Becker-m" ); + csRef<iVFS> vfs = csQueryRegistry<iVFS > ( PawsManager::GetSingleton().GetObjectRegistry()); + if( vfs ) + { + csRef<iStringArray> fileList( vfs->FindFiles( "/planeshift/data/ttf/*.ttf" )); + for (size_t i = 0; i < fileList->GetSize(); i++) + { + csString fileName ( fileList->Get (i)); + fileName.DeleteAt( 0, 21 ); // remove the leading path. + fileName.ReplaceAll( ".ttf", "" ); + textFont->NewOption( fileName.GetData() ); + } + } + else + { + Error1( "pawsConfigShortcutWindow::PostSetup unable to find vfs for font list" ); + } + + textSize = (pawsScrollBar*)FindWidget("textSize"); if(!textSize) { @@ -270,39 +282,12 @@ textSize->SetCurrentValue(MenuBar->GetFontSize()); - { - //const char * buttonFontName = MenuBar->GetButtonFontName(); -const char * buttonFontName = ((pawsShortcutWindow*)ShortcutMenu)->GetFontName(); - if( strcmp( buttonFontName, "/planeshift/data/ttf/LiberationSans-Regular.ttf")==0 || strcmp( buttonFontName, "/this/data/ttf/LiberationSans-Regular.ttf")==0 ) - { - textFont->Select(0); - } - else if( strcmp( buttonFontName, "/planeshift/data/ttf/LiberationSerif-Regular.ttf")==0 || strcmp( buttonFontName, "/this/data/ttf/LiberationSerif-Regular.ttf")==0 ) - { - textFont->Select(1); - } - else if( strcmp( buttonFontName, "/planeshift/data/ttf/LiberationMono-Regular.ttf")==0 || strcmp( buttonFontName, "/this/data/ttf/LiberationMono-Regular.ttf")==0 ) - { - textFont->Select(2); - } - else if( strcmp( buttonFontName, "/planeshift/data/ttf/sonora.ttf")==0 || strcmp( buttonFontName, "/this/data/ttf/sonora.ttf")==0 ) - { - textFont->Select(3); - } - else if( strcmp( buttonFontName, "/planeshift/data/ttf/cupandtalon.ttf")==0 || strcmp( buttonFontName, "/this/data/ttf/cupandtalon.ttf")==0 ) - { - textFont->Select(4); - } - else if( strcmp( buttonFontName, "/planeshift/data/ttf/scurlock.ttf")==0 || strcmp( buttonFontName, "/this/data/ttf/scurlock.ttf")==0 ) - { - textFont->Select(5); - } - else if( strcmp( buttonFontName, "/planeshift/data/ttf/becker-m.ttf")==0 || strcmp( buttonFontName, "/this/data/ttf/becker-m.ttf")==0 ) - { - textFont->Select(6); - } - } + csString tFontName=csString(((pawsShortcutWindow*)ShortcutMenu)->GetFontName()); + tFontName.DeleteAt(0,21); + tFontName.ReplaceAll(".ttf","" ); + textFont->Select( tFontName.GetData() ); + loaded= true; dirty = false; return true; @@ -331,10 +316,10 @@ healthAndMana->GetState() ? "yes" : "no"); xml.AppendFmt("<buttonBackground on=\"%s\" />\n", buttonBackground->GetState() ? "yes" : "no"); - xml.AppendFmt("<textFont value=\"%d\" />\n", - int(textFont->GetSelectedRowNum())); xml.AppendFmt("<textSize value=\"%d\" />\n", int(textSize->GetCurrentValue())); + xml.AppendFmt("<textFont value=\"%s\" />\n", + textFont->GetSelectedRowString().GetData()); xml.AppendFmt("<textSpacing value=\"%d\" />\n", int(textSpacing->GetCurrentValue())); xml += "</shortcut>\n"; @@ -376,7 +361,7 @@ { if(textSize->GetCurrentValue() < 1) textSize->SetCurrentValue(1,false); - PickText( textFont->GetSelectedRowNum(), textSize->GetCurrentValue() ); + PickText( textFont->GetSelectedRowString(), textSize->GetCurrentValue() ); MenuBar->LayoutButtons(); } else if(wdg == textSpacing && loaded) @@ -535,46 +520,14 @@ return true; } -void pawsConfigShortcut::PickText( int index, int size ) +void pawsConfigShortcut::PickText( const char * fontName, int size ) { - switch( index ) - { - case 0 : - { - MenuBar->SetButtonFont( "/planeshift/data/ttf/LiberationSans-Regular.ttf", size ); - } - break; - case 1 : - { - MenuBar->SetButtonFont( "/planeshift/data/ttf/LiberationSerif-Regular.ttf", size ); - } - break; - case 2 : - { - MenuBar->SetButtonFont( "/planeshift/data/ttf/LiberationMono-Regular.ttf", size ); - } - break; - case 3 : - { - MenuBar->SetButtonFont( "/planeshift/data/ttf/sonora.ttf", size ); - } - break; - case 4 : - { - MenuBar->SetButtonFont( "/planeshift/data/ttf/cupandtalon.ttf", size ); - } - break; - case 5 : - { - MenuBar->SetButtonFont( "/planeshift/data/ttf/scurlock.ttf", size ); - } - break; - case 6 : - { - MenuBar->SetButtonFont( "/planeshift/data/ttf/becker-m.ttf", size ); - } - break; - } + csString fontPath( "/planeshift/data/ttf/"); + fontPath += fontName; + fontPath += ".ttf"; + SetFont( fontPath, size ); + MenuBar->SetFont( fontPath, size ); + MenuBar->SetButtonFont( fontPath, size ); if( loaded ) { @@ -588,7 +541,7 @@ void pawsConfigShortcut::OnListAction(pawsListBox* selected, int status) { - PickText( textFont->GetSelectedRowNum(), textSize->GetCurrentValue() ); + PickText( textFont->GetSelectedRowString(), textSize->GetCurrentValue() ); MenuBar->LayoutButtons(); MenuBar->OnResize(); ((pawsShortcutWindow*)ShortcutMenu)->Draw(); Modified: trunk/src/client/gui/pawsconfigshortcut.h =================================================================== --- trunk/src/client/gui/pawsconfigshortcut.h 2014-02-05 00:51:32 UTC (rev 9240) +++ trunk/src/client/gui/pawsconfigshortcut.h 2014-02-05 02:45:17 UTC (rev 9241) @@ -24,6 +24,11 @@ #include <csutil/array.h> #include <iutil/document.h> +#include <csutil/csstring.h> +#include <csutil/stringarray.h> +#include <csutil/array.h> + + // PAWS INCLUDES #include "paws/pawswidget.h" #include "paws/pawscombo.h" @@ -60,7 +65,7 @@ virtual bool SaveConfig(); virtual void SetDefault(); - void PickText( int index, int size ); + void PickText( const char * fontName, int size ); protected: Modified: trunk/src/client/gui/pawsscrollmenu.cpp =================================================================== --- trunk/src/client/gui/pawsscrollmenu.cpp 2014-02-05 00:51:32 UTC (rev 9240) +++ trunk/src/client/gui/pawsscrollmenu.cpp 2014-02-05 02:45:17 UTC (rev 9241) @@ -681,6 +681,7 @@ button->SetID(Index); button->SetName(name); button->SetEnabled(IsEnabled); + button->SetFont( fontName,fontSize ); if(!icon.IsEmpty()) { @@ -973,18 +974,27 @@ { ((pawsDnDButton*)Buttons[i])->SetFont(Font, size); } + } char const * pawsScrollMenu::GetButtonFontName( ) { - if( ((pawsDnDButton*)Buttons[0])->GetFontName()==NULL ) + if( Buttons[0]!=NULL ) { - return PawsManager::GetSingleton().GetPrefs()->GetDefaultFontName(); + if( ((pawsDnDButton*)Buttons[0])->GetFontName()==NULL ) + { + return PawsManager::GetSingleton().GetPrefs()->GetDefaultFontName(); + } + return ((pawsDnDButton*)Buttons[0])->GetFontName(); } - return ((pawsDnDButton*)Buttons[0])->GetFontName(); + return NULL; } float pawsScrollMenu::GetButtonFontSize( ) { - return ((pawsDnDButton*)Buttons[0])->GetFontSize(); + if( Buttons[0]!=NULL ) + { + return ((pawsDnDButton*)Buttons[0])->GetFontSize(); + } + return 10; //if something DOES end up using the font and there's no size defined, there should be a useful default } Modified: trunk/src/client/gui/shortcutwindow.cpp =================================================================== --- trunk/src/client/gui/shortcutwindow.cpp 2014-02-05 00:51:32 UTC (rev 9240) +++ trunk/src/client/gui/shortcutwindow.cpp 2014-02-05 02:45:17 UTC (rev 9241) @@ -995,8 +995,11 @@ bool pawsShortcutWindow::LoadUserPrefs() { - csRef<iDocument> doc; - csRef<iDocumentNode> root, mainNode, optionNode; + csRef<iDocument> doc; + csRef<iDocumentNode> root, + mainNode, + optionNode, + optionNode2; csString fileName; fileName = "/planeshift/userdata/options/configshortcut.xml"; @@ -1132,23 +1135,28 @@ } optionNode = mainNode->GetNode("textSize"); - if(optionNode != NULL) - MenuBar->SetButtonFont( MenuBar->GetButtonFontName(), optionNode->GetAttributeValueAsInt("value", true)); - else + if(optionNode == NULL) { Error1("pawsShortcutWindow::LoadUserPrefs unable to retrieve textSize node"); } - optionNode = mainNode->GetNode("textFont"); - if(optionNode != NULL) + optionNode2 = mainNode->GetNode("textFont"); + if(optionNode2 == NULL) { - MenuBar->SetButtonFont(optionNode->GetAttributeValue("value"), MenuBar->GetFontSize()); + Error1("pawsShortcutWindow::LoadUserPrefs unable to retrieve textFont node"); } - else + + if( optionNode != NULL && optionNode2 != NULL ) { - Error1("pawsShortcutWindow::LoadUserPrefs unable to retrieve textFont node"); + csString fontPath( "/planeshift/data/ttf/"); + fontPath += optionNode2->GetAttributeValue("value"); + fontPath += ".ttf"; + SetFont( fontPath, optionNode->GetAttributeValueAsInt("value", true) ); + MenuBar->SetFont( fontPath, optionNode->GetAttributeValueAsInt("value", true) ); } + //else use default. + optionNode = mainNode->GetNode("textSpacing"); if(optionNode != NULL) MenuBar->SetButtonPaddingWidth( optionNode->GetAttributeValueAsInt("value", true)); Modified: trunk/src/common/paws/pawslistbox.cpp =================================================================== --- trunk/src/common/paws/pawslistbox.cpp 2014-02-05 00:51:32 UTC (rev 9240) +++ trunk/src/common/paws/pawslistbox.cpp 2014-02-05 02:45:17 UTC (rev 9241) @@ -112,6 +112,8 @@ autoResize = true; autoUpdateScroll= true; selectable = true; + + columnHeight = 0; } pawsListBox::pawsListBox(const pawsListBox &origin) Modified: trunk/src/common/paws/pawslistbox.h =================================================================== --- trunk/src/common/paws/pawslistbox.h 2014-02-05 00:51:32 UTC (rev 9240) +++ trunk/src/common/paws/pawslistbox.h 2014-02-05 02:45:17 UTC (rev 9241) @@ -55,6 +55,8 @@ widgetNode = NULL; sortFunc = NULL; sortable = true; + width = 0; + height = 0; } int width; Modified: trunk/src/server/gem.cpp =================================================================== --- trunk/src/server/gem.cpp 2014-02-05 00:51:32 UTC (rev 9240) +++ trunk/src/server/gem.cpp 2014-02-05 02:45:17 UTC (rev 9241) @@ -4457,16 +4457,25 @@ asp->SetImage(image); } + //psGUIActiveMagicMessage outgoing(GetClientID(), activeSpells, GetActiveMagicSequence()); // <---add message index tracking! + //outgoing.SendMessage(); + SendActiveSpells(); +} + +void gemActor::SendActiveSpells() +{ psGUIActiveMagicMessage outgoing(GetClientID(), activeSpells, GetActiveMagicSequence()); // <---add message index tracking! outgoing.SendMessage(); } + bool gemActor::RemoveActiveSpell(ActiveSpell* asp) { if(activeSpells.Delete(asp)) { - psGUIActiveMagicMessage outgoing(GetClientID(), activeSpells, GetActiveMagicSequence()); // <---add message index tracking! - outgoing.SendMessage(); + //psGUIActiveMagicMessage outgoing(GetClientID(), activeSpells, GetActiveMagicSequence()); // <---add message index tracking! + //outgoing.SendMessage(); + SendActiveSpells(); return true; } return false; Modified: trunk/src/server/gem.h =================================================================== --- trunk/src/server/gem.h 2014-02-05 00:51:32 UTC (rev 9240) +++ trunk/src/server/gem.h 2014-02-05 02:45:17 UTC (rev 9241) @@ -1784,6 +1784,7 @@ void InvokeMovementScripts(); void AddActiveSpell(ActiveSpell* asp); + void SendActiveSpells(); bool RemoveActiveSpell(ActiveSpell* asp); ActiveSpell* FindActiveSpell(const csString &name, SPELL_TYPE type); int ActiveSpellCount(const csString &name); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |