From: <hei...@us...> - 2008-08-07 12:54:49
|
Revision: 2024 http://planeshift.svn.sourceforge.net/planeshift/?rev=2024&view=rev Author: heinchen Date: 2008-08-07 12:54:57 +0000 (Thu, 07 Aug 2008) Log Message: ----------- fix fs#1971: Turn off/mouse over lables for items without turning off character labels. Modified Paths: -------------- trunk/data/gui/configentitylabels.xml trunk/docs/history.txt trunk/src/client/entitylabels.cpp trunk/src/client/entitylabels.h trunk/src/client/gui/pawsconfigentitylabels.cpp trunk/src/client/gui/pawsconfigentitylabels.h Modified: trunk/data/gui/configentitylabels.xml =================================================================== --- trunk/data/gui/configentitylabels.xml 2008-08-07 11:55:39 UTC (rev 2023) +++ trunk/data/gui/configentitylabels.xml 2008-08-07 12:54:57 UTC (rev 2024) @@ -3,27 +3,31 @@ <widget name="ConfigEntityLabels" factory="pawsConfigEntityLabels" visible="no" savepositions="no" movable="no" resizable="no"> - <frame x="225" y="10" width="400" height="300" border="no" /> + <frame x="225" y="10" width="420" height="300" border="yes" /> <font name="/planeshift/data/ttf/LiberationSans-Regular.ttf" r="200" g="200" b="200" size="10" scalefont="no" /> - <widget name="visibility" factory="pawsRadioButtonGroup"> - <frame x="10" y="10" width="190" height="120" /> + <widget name="visibilityCreatures" factory="pawsRadioButtonGroup"> + <frame x="10" y="10" width="190" height="120" border="no" /> + <widget factory="pawsTextBox" name=""> + <frame x="0" y="0" width="180" height="20" border="no" /> + <text string="Creatures:"/> + </widget> <widget name="always" factory="pawsRadioButton" id="0"> - <frame x="10" y="10" width="190" height="30" /> + <frame x="10" y="15" width="190" height="30" /> <text string="Always visible" position="right"/> </widget> <widget name="mouse" factory="pawsRadioButton" id="1"> - <frame x="10" y="50" width="190" height="30" /> + <frame x="10" y="55" width="190" height="30" /> <text string="Visible on mouse" position="right"/> </widget> <widget name="never" factory="pawsRadioButton" id="2"> - <frame x="10" y="90" width="190" height="30" /> + <frame x="10" y="95" width="190" height="30" /> <text string="Invisible" position="right"/> </widget> </widget> <widget name="content" factory="pawsRadioButtonGroup"> - <frame x="10" y="160" width="190" height="80" /> + <frame x="10" y="160" width="190" height="80" border="no" /> <widget name="guild" factory="pawsRadioButton" id="0"> <frame x="10" y="10" width="190" height="30" /> <text string="Name and guild" position="right"/> @@ -34,6 +38,26 @@ </widget> </widget> + <widget name="visibilityItems" factory="pawsRadioButtonGroup"> + <frame x="210" y="10" width="190" height="120" border="no" /> + <widget factory="pawsTextBox" name=""> + <frame x="0" y="0" width="180" height="20" border="no" /> + <text string="Items:"/> + </widget> + <widget name="always" factory="pawsRadioButton" id="0"> + <frame x="10" y="15" width="190" height="30" /> + <text string="Always visible" position="right"/> + </widget> + <widget name="mouse" factory="pawsRadioButton" id="1"> + <frame x="10" y="55" width="190" height="30" /> + <text string="Visible on mouse" position="right"/> + </widget> + <widget name="never" factory="pawsRadioButton" id="2"> + <frame x="10" y="95" width="190" height="30" /> + <text string="Invisible" position="right"/> + </widget> + </widget> + </widget> </widget_description> Modified: trunk/docs/history.txt =================================================================== --- trunk/docs/history.txt 2008-08-07 11:55:39 UTC (rev 2023) +++ trunk/docs/history.txt 2008-08-07 12:54:57 UTC (rev 2024) @@ -1,6 +1,6 @@ *** 2008-08-06 by Andreas Heinchen - Fixed FS#1241, patch from Arerano -- Fixed FS#190, patch by Peeg +- Fixed FS#190, FS#1971 patch by Peeg *** 2008-08-06 by Andreas Heinchen - Restricting changename with 'forceall' option to gm3 and above Modified: trunk/src/client/entitylabels.cpp =================================================================== --- trunk/src/client/entitylabels.cpp 2008-08-07 11:55:39 UTC (rev 2023) +++ trunk/src/client/entitylabels.cpp 2008-08-07 12:54:57 UTC (rev 2024) @@ -64,7 +64,8 @@ psEntityLabels::psEntityLabels() { - visibility = LABEL_ALWAYS; + visCreatures = LABEL_ONMOUSE; + visItems = LABEL_ONMOUSE; showGuild = true; underMouse = NULL; @@ -104,15 +105,16 @@ return true; } -void psEntityLabels::Configure(psEntityLabelVisib _visibility, bool _showGuild) +void psEntityLabels::Configure(psEntityLabelVisib _visCreatures, psEntityLabelVisib _visItems, bool _showGuild) { // Hide all on changed visibility to refresh what we're showing - if (visibility != _visibility) + if (visCreatures != _visCreatures || visItems != _visItems) HideAllLabels(); bool refreshGuilds = (showGuild != _showGuild); - visibility = _visibility; + visCreatures = _visCreatures; + visItems = _visItems; showGuild = _showGuild; // Refresh guild labels if our display option has changed @@ -120,9 +122,10 @@ RefreshGuildLabels(); } -void psEntityLabels::GetConfiguration(psEntityLabelVisib & _visibility, bool & _showGuild) +void psEntityLabels::GetConfiguration(psEntityLabelVisib & _visCreatures, psEntityLabelVisib & _visItems, bool & _showGuild) { - _visibility = visibility; + _visCreatures = visCreatures; + _visItems = visItems; _showGuild = showGuild; } @@ -135,11 +138,12 @@ if (celClient->GetMainPlayer() == NULL) return false; // Not loaded yet - if (visibility == LABEL_ALWAYS) + if (visItems == LABEL_ALWAYS || visCreatures == LABEL_ALWAYS) { UpdateVisibility(); } - else if (visibility == LABEL_ONMOUSE) + + if (visItems == LABEL_ONMOUSE || visCreatures == LABEL_ONMOUSE) { UpdateMouseover(); } @@ -328,15 +332,18 @@ { CS_ASSERT_MSG("Effects Manager must exist before loading entity labels!", psengine->GetEffectManager() ); - if (visibility == LABEL_NEVER) + if (visCreatures == LABEL_NEVER && visItems == LABEL_NEVER) return; if(object->GetEntityLabel()) { RepaintObjectLabel( object ); - } else { + } + else + { CreateLabelOfObject( object ); - if (visibility == LABEL_ONMOUSE) + + if (visCreatures == LABEL_ONMOUSE || visItems == LABEL_ONMOUSE) { psPoint mouse = PawsManager::GetSingleton().GetMouse()->GetPosition(); GEMClientObject *um = psengine->GetMainWidget()->FindMouseOverObject(mouse.x, mouse.y); @@ -361,6 +368,8 @@ fileName = CONFIG_FILE_NAME_DEF; } + //csString fileName = CONFIG_FILE_NAME_DEF; + doc = ParseFile(psengine->GetObjectRegistry(), fileName); if (doc == NULL) { @@ -380,16 +389,17 @@ return false; } + // Players, NPCs, monsters optionNode = entityLabelsNode->GetNode("Visibility"); if (optionNode != NULL) { option = optionNode->GetAttributeValue("value"); if (option == "always") - visibility = LABEL_ALWAYS; + visCreatures = LABEL_ALWAYS; else if (option == "mouse") - visibility = LABEL_ONMOUSE; + visCreatures = LABEL_ONMOUSE; else if (option == "never") - visibility = LABEL_NEVER; + visCreatures = LABEL_NEVER; } optionNode = entityLabelsNode->GetNode("ShowGuild"); @@ -399,6 +409,19 @@ showGuild = (option == "yes"); } + // Items + optionNode = entityLabelsNode->GetNode("VisibilityItems"); + if (optionNode != NULL) + { + option = optionNode->GetAttributeValue("value"); + if (option == "always") + visItems = LABEL_ALWAYS; + else if (option == "mouse") + visItems = LABEL_ONMOUSE; + else if (option == "never") + visItems = LABEL_NEVER; + } + return true; } @@ -417,7 +440,11 @@ // Don't show other player names unless introduced. if (object->GetObjectType() == GEM_ACTOR && !(object->Flags() & psPersistActor::NAMEKNOWN)) continue; - + + // Don't show labels of stuff whose label isn't always visible + if (!ShowLabel(object->GetObjectType(), LABEL_ALWAYS)) + continue; + // Only show labels within range csVector3 there = mesh->GetMovable()->GetPosition(); int range = (object->GetObjectType() == GEM_ITEM) ? RANGE_TO_SEE_ITEM_LABELS : RANGE_TO_SEE_ACTOR_LABELS ; @@ -437,6 +464,13 @@ // Find out the object underMouse = psengine->GetMainWidget()->FindMouseOverObject(mouse.x, mouse.y); + if(underMouse) + { + // Don't show labels of stuff whose label isn't only visible on mouse over + if(!ShowLabel(underMouse->GetObjectType(), LABEL_ONMOUSE)) + return; + } + // Is this a new object? if (underMouse != lastUnderMouse) { @@ -469,18 +503,27 @@ bool psEntityLabels::SaveToFile() { csString xml; - csString visibilityStr, showGuildStr; + csString visCreaturesStr, visItemsStr, showGuildStr; - switch (visibility) + switch (visCreatures) { - case LABEL_ALWAYS: visibilityStr = "always"; break; - case LABEL_ONMOUSE: visibilityStr = "mouse"; break; - case LABEL_NEVER: visibilityStr = "never"; break; + case LABEL_ALWAYS: visCreaturesStr = "always"; break; + case LABEL_ONMOUSE: visCreaturesStr = "mouse"; break; + case LABEL_NEVER: visCreaturesStr = "never"; break; } + + switch (visItems) + { + case LABEL_ALWAYS: visItemsStr = "always"; break; + case LABEL_ONMOUSE: visItemsStr = "mouse"; break; + case LABEL_NEVER: visItemsStr = "never"; break; + } + showGuildStr = showGuild ? "yes" : "no"; xml = "<EntityLabels>\n"; - xml += " <Visibility value=\"" + visibilityStr + "\"/>\n"; + xml += " <Visibility value=\"" + visCreaturesStr + "\"/>\n"; + xml += " <VisibilityItems value=\"" + visItemsStr + "\"/>\n"; xml += " <ShowGuild value=\"" + showGuildStr + "\"/>\n"; xml += "</EntityLabels>\n"; @@ -546,3 +589,18 @@ for (size_t i=0; i<entities.GetSize(); i++) OnObjectArrived( entities.Get(i) ); } + +bool psEntityLabels::ShowLabel(GEMOBJECT_TYPE type, psEntityLabelVisib vis) +{ + if(type == GEM_ACTOR) + { + return visCreatures == vis; + } + + if(type == GEM_ITEM) + { + return visItems == vis; + } + + return false; +} Modified: trunk/src/client/entitylabels.h =================================================================== --- trunk/src/client/entitylabels.h 2008-08-07 11:55:39 UTC (rev 2023) +++ trunk/src/client/entitylabels.h 2008-08-07 12:54:57 UTC (rev 2024) @@ -74,12 +74,12 @@ /** * Sets options for label behaviour: */ - void Configure(psEntityLabelVisib visibility, bool showGuild); + void Configure(psEntityLabelVisib visCreatures, psEntityLabelVisib visItems, bool showGuild); /** * Gets options for label behaviour: */ - void GetConfiguration(psEntityLabelVisib & visibility, bool & showGuild); + void GetConfiguration(psEntityLabelVisib & visCreatures, psEntityLabelVisib & visItems, bool & showGuild); /** * Reads options for label behaviour from file: @@ -151,11 +151,14 @@ * Deletes label from entity */ void DeleteLabelOfObject( GEMClientObject* object ); - + + + bool ShowLabel(GEMOBJECT_TYPE type, psEntityLabelVisib vis); /** * Configuration options */ - psEntityLabelVisib visibility; + psEntityLabelVisib visCreatures; + psEntityLabelVisib visItems; bool showGuild; // should the label contain name of character's guild ? /** Modified: trunk/src/client/gui/pawsconfigentitylabels.cpp =================================================================== --- trunk/src/client/gui/pawsconfigentitylabels.cpp 2008-08-07 11:55:39 UTC (rev 2023) +++ trunk/src/client/gui/pawsconfigentitylabels.cpp 2008-08-07 12:54:57 UTC (rev 2024) @@ -50,33 +50,54 @@ bool pawsConfigEntityLabels::PostSetup() { - visibilityRadioGroup = dynamic_cast<pawsRadioButtonGroup*> (FindWidget("visibility")); - if (visibilityRadioGroup == NULL) + visCreaturesRadioGroup = dynamic_cast<pawsRadioButtonGroup*> (FindWidget("visibilityCreatures")); + if (visCreaturesRadioGroup == NULL) return false; + + visItemsRadioGroup = dynamic_cast<pawsRadioButtonGroup*> (FindWidget("visibilityItems")); + if(visItemsRadioGroup == NULL) + return false; + contentRadioGroup = dynamic_cast<pawsRadioButtonGroup*> (FindWidget("content")); if (contentRadioGroup == NULL) return false; + return true; } bool pawsConfigEntityLabels::LoadConfig() { - psEntityLabelVisib visibility; + psEntityLabelVisib visCreatures; + psEntityLabelVisib visItems; bool showGuild; - entityLabels->GetConfiguration(visibility, showGuild); - switch (visibility) + entityLabels->GetConfiguration(visCreatures, visItems, showGuild); + + switch (visCreatures) { case LABEL_ALWAYS: - visibilityRadioGroup->SetActive("always"); + visCreaturesRadioGroup->SetActive("always"); break; case LABEL_ONMOUSE: - visibilityRadioGroup->SetActive("mouse"); + visCreaturesRadioGroup->SetActive("mouse"); break; case LABEL_NEVER: - visibilityRadioGroup->SetActive("never"); + visCreaturesRadioGroup->SetActive("never"); break; } + + switch (visItems) + { + case LABEL_ALWAYS: + visItemsRadioGroup->SetActive("always"); + break; + case LABEL_ONMOUSE: + visItemsRadioGroup->SetActive("mouse"); + break; + case LABEL_NEVER: + visItemsRadioGroup->SetActive("never"); + break; + } if (showGuild) contentRadioGroup->SetActive("guild"); @@ -89,25 +110,34 @@ bool pawsConfigEntityLabels::SaveConfig() { - psEntityLabelVisib visibility; + psEntityLabelVisib visCreatures; + psEntityLabelVisib visItems; bool showGuild; csString activeVisib; - activeVisib = visibilityRadioGroup->GetActive(); + activeVisib = visCreaturesRadioGroup->GetActive(); if (activeVisib == "always") - visibility = LABEL_ALWAYS; + visCreatures = LABEL_ALWAYS; else if (activeVisib == "mouse") - visibility = LABEL_ONMOUSE; + visCreatures = LABEL_ONMOUSE; else // if (activeVisib == "never") - visibility = LABEL_NEVER; + visCreatures = LABEL_NEVER; + activeVisib = visItemsRadioGroup->GetActive(); + if (activeVisib == "always") + visItems = LABEL_ALWAYS; + else if (activeVisib == "mouse") + visItems = LABEL_ONMOUSE; + else // if (activeVisib == "never") + visItems = LABEL_NEVER; + if (contentRadioGroup->GetActive() == "guild") showGuild = true; else showGuild = false; - entityLabels->Configure(visibility, showGuild); + entityLabels->Configure(visCreatures, visItems, showGuild); entityLabels->SaveToFile(); dirty = false; return true; @@ -115,14 +145,15 @@ void pawsConfigEntityLabels::SetDefault() { - visibilityRadioGroup->SetActive("always"); + visCreaturesRadioGroup->SetActive("mouse"); + visItemsRadioGroup->SetActive("mouse"); contentRadioGroup->SetActive("guild"); dirty = true; } bool pawsConfigEntityLabels::OnChange(pawsWidget * widget) { - if ((widget == visibilityRadioGroup) || (widget == contentRadioGroup)) + if ((widget == visCreaturesRadioGroup) || (widget == visItemsRadioGroup) || (widget == contentRadioGroup)) dirty = true; return true; Modified: trunk/src/client/gui/pawsconfigentitylabels.h =================================================================== --- trunk/src/client/gui/pawsconfigentitylabels.h 2008-08-07 11:55:39 UTC (rev 2023) +++ trunk/src/client/gui/pawsconfigentitylabels.h 2008-08-07 12:54:57 UTC (rev 2024) @@ -48,7 +48,7 @@ protected: psEntityLabels * entityLabels; - pawsRadioButtonGroup * visibilityRadioGroup, * contentRadioGroup; + pawsRadioButtonGroup *visCreaturesRadioGroup, *visItemsRadioGroup, *contentRadioGroup; }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |