From: <Ven...@us...> - 2008-11-22 06:43:55
|
Revision: 2466 http://planeshift.svn.sourceforge.net/planeshift/?rev=2466&view=rev Author: Vengeance2001 Date: 2008-11-22 06:43:45 +0000 (Sat, 22 Nov 2008) Log Message: ----------- Now popup menus that originate from different quests have the names of their respective quests above each one. This is important now that we have relaxed the requirement to only have one quest active at a time per npc. Also, there is now a bold text option for any font in any widget. This bolding is used for the headings. Modified Paths: -------------- trunk/src/client/gui/pawsilluminationwindow.cpp trunk/src/common/net/messages.cpp trunk/src/common/paws/pawslistbox.cpp trunk/src/common/paws/pawslistbox.h trunk/src/common/paws/pawsprefmanager.h trunk/src/common/paws/pawstextwrap.cpp trunk/src/common/paws/pawswidget.cpp trunk/src/common/paws/pawswidget.h trunk/src/server/bulkobjects/dictionary.cpp trunk/src/server/bulkobjects/dictionary.h trunk/src/server/bulkobjects/pscharacter.cpp trunk/src/server/questmanager.cpp trunk/src/server/questmanager.h Modified: trunk/src/client/gui/pawsilluminationwindow.cpp =================================================================== --- trunk/src/client/gui/pawsilluminationwindow.cpp 2008-11-22 01:45:06 UTC (rev 2465) +++ trunk/src/client/gui/pawsilluminationwindow.cpp 2008-11-22 06:43:45 UTC (rev 2466) @@ -26,7 +26,7 @@ // PAWS INCLUDES #include "pawsilluminationwindow.h" -#include "paws/pawsprefmanager.h" // For FONT_DROPSHADOW - DrawColorWidgetText (maybe move DrawColorWidgetText to pawswidget?) +#include "paws/pawsprefmanager.h" // For FONT_STYLE_DROPSHADOW - DrawColorWidgetText (maybe move DrawColorWidgetText to pawswidget?) #include "paws/pawstextbox.h" #include "paws/pawsmanager.h" #include "net/messages.h" @@ -300,7 +300,7 @@ csRef<iFont> font = GetFont(); int style = GetFontStyle(); - if (style & FONT_DROPSHADOW) + if (style & FONT_STYLE_DROPSHADOW) graphics2D->Write( font, x+2, y+2, GetFontShadowColour(), -1, text ); graphics2D->Write( font, x, y, color, -1, text); Modified: trunk/src/common/net/messages.cpp =================================================================== --- trunk/src/common/net/messages.cpp 2008-11-22 01:45:06 UTC (rev 2465) +++ trunk/src/common/net/messages.cpp 2008-11-22 06:43:45 UTC (rev 2466) @@ -7190,9 +7190,19 @@ { xml = "<dlgmenu><options>"; + int counter=1; for( size_t i = 0; i < responses.GetSize(); i++ ) { - xml.AppendFmt("<row><text>%d. %s</text>",i+1, responses[i].menuText.GetData() ); + csString choice = responses[i].menuText.GetData(); + if (choice.GetAt(0) == 'h' && choice.GetAt(1) == ':') // heading tag + { + choice.DeleteAt(0,2); // take out tag + xml.AppendFmt("<row heading=\"1\"><text>%s</text>", choice.GetData() ); + } + else + { + xml.AppendFmt("<row><text>%d. %s</text>",counter++, responses[i].menuText.GetData() ); + } xml.AppendFmt("<trig>%s</trig></row>",responses[i].triggerText.GetData() ); } xml += "</options></dlgmenu>"; Modified: trunk/src/common/paws/pawslistbox.cpp =================================================================== --- trunk/src/common/paws/pawslistbox.cpp 2008-11-22 01:45:06 UTC (rev 2465) +++ trunk/src/common/paws/pawslistbox.cpp 2008-11-22 06:43:45 UTC (rev 2466) @@ -761,8 +761,13 @@ if ( strcmp( node->GetValue(), xmlbinding_row ) == 0 ) { pawsListBoxRow *row = NewRow(count++); + if (node->GetAttributeValueAsBool("heading") == true) + { + row->SetHeading(true); + } int x; for (x=0; x<totalColumns; x++) + { if (columnDef[x].xmlbinding.Length() > 0) { pawsWidget *columnwidget = row->GetColumn(x); @@ -784,6 +789,7 @@ return false; } } + } } } @@ -812,6 +818,14 @@ if (selected>0) { selected--; + if (GetSelectedRow()->IsHeading()) + { + if (selected > 0) + selected--; + else + selected++; // go back where we were if nothing is above the heading + } + Select(GetSelectedRow()); } } @@ -820,6 +834,13 @@ if (selected<totalRows-1) { selected++; + if (GetSelectedRow()->IsHeading()) + { + if (selected < totalRows-1) + selected++; + else + selected--; // go back where we were if nothing is above the heading + } Select(GetSelectedRow()); } } @@ -1095,6 +1116,7 @@ pawsListBoxRow::pawsListBoxRow() { + isHeading = false; } @@ -1106,6 +1128,10 @@ bool pawsListBoxRow::OnMouseDown( int button, int modifiers, int x, int y ) { + // Heading rows are not clickable or selectable + if (isHeading) + return true; + pawsListBox* parentBox = (pawsListBox*)parent; // mouse wheel @@ -1118,6 +1144,10 @@ bool pawsListBoxRow::OnDoubleClick(int button, int modifiers, int x, int y) { + // Heading rows are not clickable or selectable + if (isHeading) + return false; + pawsListBox * parentBox = (pawsListBox *)parent; if (button != csmbWheelUp && button != csmbWheelDown) @@ -1198,6 +1228,16 @@ title->SetID(column); } +void pawsListBoxRow::SetHeading(bool flag) +{ + isHeading = flag; + + for (size_t i=0; i<columns.GetSize(); i++) + { + columns[i]->SetFontStyle(flag ? FONT_STYLE_BOLD : DEFAULT_FONT_STYLE); + } +} + int pawsListBox::GetRowCount() { return (int)rows.GetSize(); Modified: trunk/src/common/paws/pawslistbox.h =================================================================== --- trunk/src/common/paws/pawslistbox.h 2008-11-22 01:45:06 UTC (rev 2465) +++ trunk/src/common/paws/pawslistbox.h 2008-11-22 06:43:45 UTC (rev 2466) @@ -89,17 +89,20 @@ bool OnKeyDown(int keyCode, int keyChar, int modifiers); - /** - * A single mouse click (left button) highlights the row - */ + /// A single mouse click (left button) highlights the row bool OnMouseDown(int button, int modifiers, int x, int y ); - /** - * A double click selects the row. - */ + /// A double click selects the row. bool OnDoubleClick(int button, int modifiers, int x, int y); + /// Heading rows exist within the list but are not clickable + void SetHeading(bool flag); + + bool IsHeading() { return isHeading; } private: + /// Store whether this row should be a heading or not + bool isHeading; + /// Store a list of columns for easy access. csArray<pawsWidget*> columns; Modified: trunk/src/common/paws/pawsprefmanager.h =================================================================== --- trunk/src/common/paws/pawsprefmanager.h 2008-11-22 01:45:06 UTC (rev 2465) +++ trunk/src/common/paws/pawsprefmanager.h 2008-11-22 06:43:45 UTC (rev 2466) @@ -32,13 +32,11 @@ struct iGraphics2D; struct iFont; struct BorderDefinition; - class PawsManager; + #define BORDER_COLOURS 5 -#define DEFAULT_FONT_SIZE 12 -#define DFFAULT_FONT_STYLE 0 -#define FONT_DROPSHADOW 1 + /** Holds/Loads the prefs from a pref file. */ class pawsPrefManager Modified: trunk/src/common/paws/pawstextwrap.cpp =================================================================== --- trunk/src/common/paws/pawstextwrap.cpp 2008-11-22 01:45:06 UTC (rev 2465) +++ trunk/src/common/paws/pawstextwrap.cpp 2008-11-22 06:43:45 UTC (rev 2466) @@ -512,7 +512,7 @@ int a = (int) (255 - (parent->GetMinAlpha() + (parent->GetMaxAlpha()-parent->GetMinAlpha()) * parent->GetFadeVal() * 0.010)); int r, g, b; - if (style & FONT_DROPSHADOW) + if (style & FONT_STYLE_DROPSHADOW) { graphics2D->GetRGB(GetFontShadowColour(), r, g, b); graphics2D->Write( font, (int) x+2, (int) y+2, graphics2D->FindRGB(r, g, b, a), -1, text ); @@ -522,7 +522,7 @@ } else { - if (style & FONT_DROPSHADOW) + if (style & FONT_STYLE_DROPSHADOW) graphics2D->Write( font, (int) x+2, (int) y+2, GetFontShadowColour(), -1, text ); graphics2D->Write( font, (int) x, (int) y, fg, -1, text); Modified: trunk/src/common/paws/pawswidget.cpp =================================================================== --- trunk/src/common/paws/pawswidget.cpp 2008-11-22 01:45:06 UTC (rev 2465) +++ trunk/src/common/paws/pawswidget.cpp 2008-11-22 06:43:45 UTC (rev 2466) @@ -438,7 +438,7 @@ defaultFontShadowColour = graphics2D->FindRGB( r, g, b ); if (fontAttribute->GetAttributeValueAsBool( "shadow" )) - fontStyle |= FONT_DROPSHADOW; + fontStyle |= FONT_STYLE_DROPSHADOW; } // Get the frame for this widget. @@ -1093,20 +1093,28 @@ int a = (int) (255 - (parent->GetMinAlpha() + (parent->GetMaxAlpha()-parent->GetMinAlpha()) * parent->GetFadeVal() * 0.010)); int r, g, b; - if (style & FONT_DROPSHADOW) + if (style & FONT_STYLE_DROPSHADOW) { graphics2D->GetRGB(GetFontShadowColour(), r, g, b); graphics2D->Write( font, x+2, y+2, graphics2D->FindRGB(r, g, b, a), -1, text ); } graphics2D->GetRGB(GetFontColour(), r, g, b); graphics2D->Write( font, x, y, graphics2D->FindRGB(r, g, b, a), -1, text); + if (style & FONT_STYLE_BOLD) + { + graphics2D->Write( font, x+1, y, graphics2D->FindRGB(r, g, b, a), -1, text); + } } else { - if (style & FONT_DROPSHADOW) + if (style & FONT_STYLE_DROPSHADOW) graphics2D->Write( font, x+2, y+2, GetFontShadowColour(), -1, text ); graphics2D->Write( font, x, y, GetFontColour(), -1, text); + if (style & FONT_STYLE_BOLD) + { + graphics2D->Write( font, x+1, y, GetFontColour(), -1, text); + } } } @@ -2434,14 +2442,19 @@ int pawsWidget::GetFontStyle() { - if (myFont) + if (fontStyle) return fontStyle; else if (parent) return parent->GetFontStyle(); else - return DFFAULT_FONT_STYLE; + return DEFAULT_FONT_STYLE; } +void pawsWidget::SetFontStyle(int style) +{ + fontStyle = style; +} + bool pawsWidget::SelfPopulateXML( const char *xmlstr ) { csRef<iDocumentSystem> xml = csPtr<iDocumentSystem>(new csTinyDocumentSystem); Modified: trunk/src/common/paws/pawswidget.h =================================================================== --- trunk/src/common/paws/pawswidget.h 2008-11-22 01:45:06 UTC (rev 2465) +++ trunk/src/common/paws/pawswidget.h 2008-11-22 06:43:45 UTC (rev 2466) @@ -77,8 +77,13 @@ #define BORDER_ETCHED (BORDER_REVERSED|BORDER_RAISED) -#define TEXT_DROPSHADOW 1 +#define DEFAULT_FONT_SIZE 12 +#define DEFAULT_FONT_STYLE 0 +#define FONT_STYLE_DROPSHADOW 1 +#define FONT_STYLE_BOLD 2 + + enum PAWS_WIDGET_SCRIPT_EVENTS { PW_SCRIPT_EVENT_SHOW = 0, @@ -1141,10 +1146,14 @@ /** Gets the current font style. * @return fontStyle if myFont, if not then the parent's, - * or if it doesn't have a parent it returns DFFAULT_FONT_STYLE. + * or if it doesn't have a parent it returns DEFAULT_FONT_STYLE. */ int GetFontStyle(); + /** Sets the current font style. + */ + void SetFontStyle(int style); + /** Determines if the coordinates are within this widget. Typically the border or screenFrame. * @param x The x screen position. * @param y The y screen position. Modified: trunk/src/server/bulkobjects/dictionary.cpp =================================================================== --- trunk/src/server/bulkobjects/dictionary.cpp 2008-11-22 01:45:06 UTC (rev 2465) +++ trunk/src/server/bulkobjects/dictionary.cpp 2008-11-22 06:43:45 UTC (rev 2466) @@ -2375,14 +2375,15 @@ counter = 0; } -void NpcDialogMenu::AddTrigger(const csString &formatted, const csString &trigger, psQuestPrereqOp *script) +void NpcDialogMenu::AddTrigger(const csString &menuText, const csString &trigger, psQuest *quest, psQuestPrereqOp *script) { NpcDialogMenu::DialogTrigger new_trigger; - new_trigger.formatted = formatted; + new_trigger.menuText = menuText; new_trigger.trigger = trigger; + new_trigger.quest = quest; new_trigger.prerequisite = script; - new_trigger.triggerID = counter++; + new_trigger.triggerID = counter++; this->triggers.Push( new_trigger ); } @@ -2395,8 +2396,8 @@ for (size_t i=0; i < add->triggers.GetSize(); i++) { - printf("Adding '%s' to menu.\n", add->triggers[i].formatted.GetData() ); - AddTrigger(add->triggers[i].formatted, add->triggers[i].trigger, add->triggers[i].prerequisite); + printf("Adding '%s' to menu.\n", add->triggers[i].menuText.GetData() ); + AddTrigger(add->triggers[i].menuText, add->triggers[i].trigger, add->triggers[i].quest, add->triggers[i].prerequisite); } printf("Added %d triggers to menu.\n", add->triggers.GetSize() ); } @@ -2408,6 +2409,8 @@ psDialogMenuMessage menu; + csString currentQuest; + for (size_t i=0; i < counter; i++ ) { csString prereq; @@ -2433,8 +2436,18 @@ } } + // Check to see about inserting a quest heading + if (!(currentQuest == (triggers[i].quest ? triggers[i].quest->GetName() : "(Unknown)"))) + { + currentQuest = triggers[i].quest ? triggers[i].quest->GetName() : "(Unknown)"; + csString temp = "h:", temptrig = "heading"; + temp += currentQuest; + menu.AddResponse((uint32_t) i, temp, temptrig, + "", "", "", "" ); + } + menu.AddResponse((uint32_t) i, - triggers[ i ].formatted, + triggers[i].menuText, triggers[i].trigger, client->GetName(), client->GetCharacterData()->GetRaceInfo()->GetRace(), client->GetCharacterData()->GetRaceInfo()->GetHonorific(), Modified: trunk/src/server/bulkobjects/dictionary.h =================================================================== --- trunk/src/server/bulkobjects/dictionary.h 2008-11-22 01:45:06 UTC (rev 2465) +++ trunk/src/server/bulkobjects/dictionary.h 2008-11-22 06:43:45 UTC (rev 2466) @@ -304,8 +304,9 @@ struct DialogTrigger { unsigned int triggerID; - csString formatted; + csString menuText; csString trigger; + psQuest *quest; csRef<psQuestPrereqOp> prerequisite; }; @@ -317,7 +318,7 @@ NpcDialogMenu(); - void AddTrigger( const csString &formatted, const csString &trigger, psQuestPrereqOp *script=NULL ); + void AddTrigger( const csString &menuText, const csString &trigger, psQuest *quest, psQuestPrereqOp *script=NULL ); void Add( NpcDialogMenu *add); void ShowMenu( Client *client ); void SetPrerequisiteScript(psQuestPrereqOp *script); Modified: trunk/src/server/bulkobjects/pscharacter.cpp =================================================================== --- trunk/src/server/bulkobjects/pscharacter.cpp 2008-11-22 01:45:06 UTC (rev 2465) +++ trunk/src/server/bulkobjects/pscharacter.cpp 2008-11-22 06:43:45 UTC (rev 2466) @@ -2561,6 +2561,8 @@ { CS_ASSERT( quest ); // Must not be NULL + // Shame on Kayden for cutting and pasting those code from CheckQuestAvailable instead of making a distinct function for it. :) + /********************************* //first check if there is not another assigned quest with the same NPC for (size_t i=0; i<assigned_quests.GetSize(); i++) { @@ -2575,6 +2577,7 @@ return false; // Cannot have multiple quests from the same guy } } + ********************/ QuestAssignment *q = IsQuestAssigned(quest->GetID() ); if (!q) // make new entry if needed, reuse if old @@ -2767,6 +2770,7 @@ //Since the quest is not assigned, this conversation will lead to starting the quest. //Check all assigned quests, to make sure there is no other quest already started by this NPC + /***** for (size_t i=0; i<assigned_quests.GetSize(); i++) { if (assigned_quests[i]->GetQuest().IsValid() && assigned_quests[i]->assigner_id == assigner_id && @@ -2783,6 +2787,7 @@ return false; // Cannot have multiple quests from the same guy } } + ********/ if (q) //then quest in assigned list, but not PSQUEST_ASSIGNED { Modified: trunk/src/server/questmanager.cpp =================================================================== --- trunk/src/server/questmanager.cpp 2008-11-22 01:45:06 UTC (rev 2465) +++ trunk/src/server/questmanager.cpp 2008-11-22 06:43:45 UTC (rev 2466) @@ -565,7 +565,7 @@ { NpcDialogMenu *menu = new NpcDialogMenu(); - if (!BuildMenu(block, pending_triggers, menu)) + if (!BuildMenu(block, pending_triggers, mainQuest, menu)) { Error3("Could not determine menu triggers in script '%s', in line <%s>", mainQuest->GetName(),block.GetData()); @@ -894,7 +894,7 @@ return true; } -bool QuestManager::BuildMenu(const csString& block,const csStringArray& list, NpcDialogMenu *menu) +bool QuestManager::BuildMenu(const csString& block,const csStringArray& list, psQuest *quest, NpcDialogMenu *menu) { size_t start=0, end, counter = 0; csString response; @@ -914,7 +914,7 @@ block.SubString(response,start,end-start); response.Trim(); - menu->AddTrigger( response, list[ counter++ ] ); + menu->AddTrigger( response, list[ counter++ ], quest ); start = end; // Start at next Menu: or exit loop } Modified: trunk/src/server/questmanager.h =================================================================== --- trunk/src/server/questmanager.h 2008-11-22 01:45:06 UTC (rev 2465) +++ trunk/src/server/questmanager.h 2008-11-22 06:43:45 UTC (rev 2466) @@ -74,7 +74,7 @@ csString& him, csString& her, csString& it, csString& them); bool BuildTriggerList(csString& block,csStringArray& list); - bool BuildMenu(const csString& block,const csStringArray& list, NpcDialogMenu *menu); + bool BuildMenu(const csString& block,const csStringArray& list, psQuest *quest, NpcDialogMenu *menu); int GetNPCFromBlock(WordArray words,csString& current_npc); bool ParseItemList(const csString & input, csString & parsedItemList); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |