Ticket #3699: 3699_tooltip.2.patch
File 3699_tooltip.2.patch, 3.7 KB (added by , 7 years ago) |
---|
-
binaries/data/mods/public/gui/common/settings.js
186 186 { 187 187 "Name": "skirmish", 188 188 "Title": translateWithContext("map", "Skirmish"), 189 "Description": translate("A map with predefined landscape."), 189 190 "Default": true 190 191 }, 191 192 { 192 193 "Name": "random", 193 "Title": translateWithContext("map", "Random") 194 "Title": translateWithContext("map", "Random"), 195 "Description": translate("A randomly generated map.") 194 196 }, 195 197 { 196 198 "Name": "scenario", 197 "Title": translateWithContext("map", "Scenario") 199 "Title": translateWithContext("map", "Scenario"), 200 "Description": translate("A map with predefined landscape, civilizations and players.") 198 201 } 199 202 ]; 200 203 } -
binaries/data/mods/public/gui/gamesetup/gamesetup.js
322 322 if (this.selected != -1) 323 323 selectMapType(this.list_data[this.selected]); 324 324 }; 325 mapTypes.onHoverChange = function() { 326 mapTypes.tooltip = g_MapTypes.Description[this.hovered_item] || 327 translate("Select a map type."); 328 } 325 329 if (g_IsController) 326 330 mapTypes.selected = g_MapTypes.Default; 327 331 } … … 459 463 460 464 updateGameAttributes(); 461 465 }; 466 victoryConditions.onHoverChange = function() { 467 victoryConditions.tooltip = g_VictoryConditions.Description[this.hovered_item] || 468 translate("Select victory condition."); 469 }; 462 470 victoryConditions.selected = g_VictoryConditions.Default; 463 471 } 464 472 -
source/gui/CList.cpp
50 50 // Each list item has both a name (in 'list') and an associated data string (in 'list_data') 51 51 AddSetting(GUIST_CGUIList, "list"); 52 52 AddSetting(GUIST_CGUIList, "list_data"); // TODO: this should be a list of raw strings, not of CGUIStrings 53 AddSetting(GUIST_int, "hovered_item"); 53 54 54 GUI<bool>::SetSetting(this, "scrollbar", false); 55 GUI<bool>::SetSetting(this, "scrollbar", false); 56 GUI<int>::SetSetting(this, "selected", -1); 57 GUI<int>::SetSetting(this, "hovered_item", -1); 55 58 56 // Nothing is selected as default.57 GUI<int>::SetSetting(this, "selected", -1);58 59 59 // Add scroll-bar 60 60 CGUIScrollBarVertical* bar = new CGUIScrollBarVertical(); 61 61 bar->SetRightAligned(true); … … 228 228 break; 229 229 } 230 230 231 case GUIM_MOUSE_LEAVE: 232 { 233 GUI<int>::SetSetting(this, "hovered_item", -1); 234 ScriptEvent("hoverchange"); 235 break; 236 } 237 238 case GUIM_MOUSE_OVER: 239 { 240 bool scrollbar; 241 CGUIList* pList; 242 GUI<bool>::GetSetting(this, "scrollbar", scrollbar); 243 GUI<CGUIList>::GetSettingPointer(this, "list", pList); 244 float scroll = 0.f; 245 if (scrollbar) 246 scroll = GetScrollBar(0).GetPos(); 247 248 CRect rect = GetListRect(); 249 CPos mouse = GetMousePos(); 250 mouse.y += scroll; 251 int set = -1; 252 for (int i = 0; i < (int)pList->m_Items.size(); ++i) 253 { 254 if (mouse.y >= rect.top + m_ItemsYPositions[i] && 255 mouse.y < rect.top + m_ItemsYPositions[i + 1] && 256 // mouse is not over scroll-bar 257 (!scrollbar || !GetScrollBar(0).IsVisible() || 258 mouse.x < GetScrollBar(0).GetOuterRect().left || 259 mouse.x > GetScrollBar(0).GetOuterRect().right)) 260 { 261 set = i; 262 } 263 } 264 265 GUI<int>::SetSetting(this, "hovered_item", set); 266 ScriptEvent("hoverchange"); 267 break; 268 } 269 231 270 case GUIM_LOAD: 232 271 { 233 272 CStr scrollbar_style;