Index: binaries/data/mods/public/gui/common/settings.js =================================================================== --- binaries/data/mods/public/gui/common/settings.js +++ binaries/data/mods/public/gui/common/settings.js @@ -186,15 +186,18 @@ { "Name": "skirmish", "Title": translateWithContext("map", "Skirmish"), + "Description": translate("A map with a predefined landscape and number of players. Freely select the other gamesettings."), "Default": true }, { "Name": "random", - "Title": translateWithContext("map", "Random") + "Title": translateWithContext("map", "Random"), + "Description": translate("Create a unique map with a different resource distribution each time. Freely chose the number of players and teams.") }, { "Name": "scenario", - "Title": translateWithContext("map", "Scenario") + "Title": translateWithContext("map", "Scenario"), + "Description": translate("A map with a predefined landscape, civilizations and teams. Freely select the other gamesettings.") } ]; } Index: binaries/data/mods/public/gui/gamesetup/gamesetup.js =================================================================== --- binaries/data/mods/public/gui/gamesetup/gamesetup.js +++ binaries/data/mods/public/gui/gamesetup/gamesetup.js @@ -360,7 +360,7 @@ var g_Dropdowns = { "mapType": { "title": () => translate("Map Type"), - "tooltip": () => translate("Select a map type."), + "tooltip": (idx) => idx >= 0 ? g_MapTypes.Description[idx] : translate("Select a map type."), "labels": () => g_MapTypes.Title, "ids": () => g_MapTypes.Name, "default": () => g_MapTypes.Default, @@ -458,7 +458,15 @@ }, "startingResources": { "title": () => translate("Starting Resources"), - "tooltip": () => translate("Select the game's starting resources."), + "tooltip": (idx) => { + return idx >= 0 ? + sprintf( + translate("Start value of each resource: %(resources)s."), + { "resources": g_StartingResources.Resources[idx] } + ) + : + translate("Select the game's starting resources."); + }, "labels": () => g_StartingResources.Title, "ids": () => g_StartingResources.Resources, "default": () => g_StartingResources.Default, @@ -485,7 +493,7 @@ }, "victoryCondition": { "title": () => translate("Victory Condition"), - "tooltip": () => translate("Select victory condition."), + "tooltip": (idx) => idx >= 0 ? g_VictoryConditions.Description[idx] : translate("Select victory condition."), "labels": () => g_VictoryConditions.Title, "ids": () => g_VictoryConditions.Name, "default": () => g_VictoryConditions.Default, @@ -967,6 +975,10 @@ supplementDefaults(); updateGameAttributes(); }; + + dropdown.onHoverChange = function() { + this.tooltip = data.tooltip(this.hovered); + }; } function initPlayerDropdowns(name) Index: source/gui/CList.h =================================================================== --- source/gui/CList.h +++ source/gui/CList.h @@ -105,6 +105,8 @@ */ std::vector m_ItemsYPositions; + int GetHoveredItem(); + private: // Whether the list's items have been modified since last handling a message. bool m_Modified; Index: source/gui/CList.cpp =================================================================== --- source/gui/CList.cpp +++ source/gui/CList.cpp @@ -32,29 +32,29 @@ { // Add sprite_disabled! TODO - AddSetting(GUIST_float, "buffer_zone"); - AddSetting(GUIST_CStrW, "font"); - AddSetting(GUIST_bool, "scrollbar"); - AddSetting(GUIST_CStr, "scrollbar_style"); - AddSetting(GUIST_CStrW, "sound_disabled"); - AddSetting(GUIST_CStrW, "sound_selected"); - AddSetting(GUIST_CGUISpriteInstance, "sprite"); - AddSetting(GUIST_CGUISpriteInstance, "sprite_selectarea"); - AddSetting(GUIST_int, "cell_id"); - AddSetting(GUIST_EAlign, "text_align"); - AddSetting(GUIST_CColor, "textcolor"); - AddSetting(GUIST_CColor, "textcolor_selected"); - AddSetting(GUIST_int, "selected"); // Index selected. -1 is none. - AddSetting(GUIST_CStrW, "tooltip"); - AddSetting(GUIST_CStr, "tooltip_style"); + AddSetting(GUIST_float, "buffer_zone"); + AddSetting(GUIST_int, "cell_id"); + AddSetting(GUIST_CStrW, "font"); + AddSetting(GUIST_int, "hovered"); // Index hovered. -1 is none. // Each list item has both a name (in 'list') and an associated data string (in 'list_data') - AddSetting(GUIST_CGUIList, "list"); - AddSetting(GUIST_CGUIList, "list_data"); // TODO: this should be a list of raw strings, not of CGUIStrings - - GUI::SetSetting(this, "scrollbar", false); - - // Nothing is selected as default. - GUI::SetSetting(this, "selected", -1); + AddSetting(GUIST_CGUIList, "list"); + AddSetting(GUIST_CGUIList, "list_data"); // TODO: this should be a list of raw strings, not of CGUIStrings + AddSetting(GUIST_bool, "scrollbar"); + AddSetting(GUIST_CStr, "scrollbar_style"); + AddSetting(GUIST_int, "selected"); // Index selected. -1 is none. + AddSetting(GUIST_CStrW, "sound_disabled"); + AddSetting(GUIST_CStrW, "sound_selected"); + AddSetting(GUIST_CGUISpriteInstance, "sprite"); + AddSetting(GUIST_CGUISpriteInstance, "sprite_selectarea"); + AddSetting(GUIST_EAlign, "text_align"); + AddSetting(GUIST_CColor, "textcolor"); + AddSetting(GUIST_CColor, "textcolor_selected"); + AddSetting(GUIST_CStrW, "tooltip"); + AddSetting(GUIST_CStr, "tooltip_style"); + + GUI::SetSetting(this, "hovered", -1); + GUI::SetSetting(this, "scrollbar", false); + GUI::SetSetting(this, "selected", -1); // Add scroll-bar CGUIScrollBarVertical* bar = new CGUIScrollBarVertical(); @@ -194,45 +194,34 @@ break; } - bool scrollbar; - CGUIList* pList; - GUI::GetSetting(this, "scrollbar", scrollbar); - GUI::GetSettingPointer(this, "list", pList); - float scroll = 0.f; - if (scrollbar) - scroll = GetScrollBar(0).GetPos(); + int hovered = GetHoveredItem(); + if (hovered == -1) + break; + GUI::SetSetting(this, "selected", hovered); + UpdateAutoScroll(); - CRect rect = GetListRect(); - CPos mouse = GetMousePos(); - mouse.y += scroll; - int set = -1; - for (int i = 0; i < (int)pList->m_Items.size(); ++i) - { - if (mouse.y >= rect.top + m_ItemsYPositions[i] && - mouse.y < rect.top + m_ItemsYPositions[i+1] && - // mouse is not over scroll-bar - (!scrollbar || !GetScrollBar(0).IsVisible() || - mouse.x < GetScrollBar(0).GetOuterRect().left || - mouse.x > GetScrollBar(0).GetOuterRect().right)) - { - set = i; - } - } + CStrW soundPath; + if (g_SoundManager && GUI::GetSetting(this, "sound_selected", soundPath) == PSRETURN_OK && !soundPath.empty()) + g_SoundManager->PlayAsUI(soundPath.c_str(), false); - if (set != -1) - { - GUI::SetSetting(this, "selected", set); - UpdateAutoScroll(); + if (timer_Time() - m_LastItemClickTime < SELECT_DBLCLICK_RATE && hovered == m_PrevSelectedItem) + this->SendEvent(GUIM_MOUSE_DBLCLICK_LEFT_ITEM, "mouseleftdoubleclickitem"); + m_LastItemClickTime = timer_Time(); + m_PrevSelectedItem = hovered; + break; + } - CStrW soundPath; - if (g_SoundManager && GUI::GetSetting(this, "sound_selected", soundPath) == PSRETURN_OK && !soundPath.empty()) - g_SoundManager->PlayAsUI(soundPath.c_str(), false); + case GUIM_MOUSE_LEAVE: + { + GUI::SetSetting(this, "hovered", -1); + ScriptEvent("hoverchange"); + break; + } - if (timer_Time() - m_LastItemClickTime < SELECT_DBLCLICK_RATE && set == m_PrevSelectedItem) - this->SendEvent(GUIM_MOUSE_DBLCLICK_LEFT_ITEM, "mouseleftdoubleclickitem"); - m_LastItemClickTime = timer_Time(); - m_PrevSelectedItem = set; - } + case GUIM_MOUSE_OVER: + { + GUI::SetSetting(this, "hovered", GetHoveredItem()); + ScriptEvent("hoverchange"); break; } @@ -515,3 +504,29 @@ if (m_ItemsYPositions[selected+1]-rect.GetHeight() > scroll) GetScrollBar(0).SetPos(m_ItemsYPositions[selected+1]-rect.GetHeight()); } + +int CList::GetHoveredItem() +{ + bool scrollbar; + CGUIList* pList; + GUI::GetSetting(this, "scrollbar", scrollbar); + GUI::GetSettingPointer(this, "list", pList); + float scroll = 0.f; + if (scrollbar) + scroll = GetScrollBar(0).GetPos(); + + CRect rect = GetListRect(); + CPos mouse = GetMousePos(); + mouse.y += scroll; + for (int i = 0; i < (int)pList->m_Items.size(); ++i) + if (mouse.y >= rect.top + m_ItemsYPositions[i] && + mouse.y < rect.top + m_ItemsYPositions[i + 1] && + // mouse is not over scroll-bar + (!scrollbar || !GetScrollBar(0).IsVisible() || + mouse.x < GetScrollBar(0).GetOuterRect().left || + mouse.x > GetScrollBar(0).GetOuterRect().right)) + { + return i; + } + return -1; +}