Ticket #3699: 3699_tooltip.patch
File 3699_tooltip.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 battle map."), 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 random 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 scenario.") 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 if (this.hovered_item != -1) 327 mapTypes.tooltip = g_MapTypes.Description[this.hovered_item]; 328 else 329 mapTypes.tooltip = translate("Select a map type."); 330 } 325 331 if (g_IsController) 326 332 mapTypes.selected = g_MapTypes.Default; 327 333 } … … 459 465 460 466 updateGameAttributes(); 461 467 }; 468 victoryConditions.onHoverChange = function() { 469 if (this.hovered_item != -1) 470 victoryConditions.tooltip = g_VictoryConditions.Description[this.hovered_item]; 471 else 472 victoryConditions.tooltip = translate("Select victory condition."); 473 }; 462 474 victoryConditions.selected = g_VictoryConditions.Default; 463 475 } 464 476 -
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 55 GUI<bool>::SetSetting(this, "scrollbar", false); 55 56 … … 56 57 // Nothing is selected as default. 57 58 GUI<int>::SetSetting(this, "selected", -1); 58 59 60 // Nothing is covered as default 61 GUI<int>::SetSetting(this, "hovered_item", -1); 62 59 63 // Add scroll-bar 60 64 CGUIScrollBarVertical* bar = new CGUIScrollBarVertical(); 61 65 bar->SetRightAligned(true); … … 228 232 break; 229 233 } 230 234 235 case GUIM_MOUSE_LEAVE: 236 { 237 GUI<int>::SetSetting(this, "hovered_item", -1); 238 ScriptEvent("hoverchange"); 239 break; 240 } 241 242 case GUIM_MOUSE_OVER: 243 { 244 bool scrollbar; 245 CGUIList* pList; 246 GUI<bool>::GetSetting(this, "scrollbar", scrollbar); 247 GUI<CGUIList>::GetSettingPointer(this, "list", pList); 248 float scroll = 0.f; 249 if (scrollbar) 250 scroll = GetScrollBar(0).GetPos(); 251 252 CRect rect = GetListRect(); 253 CPos mouse = GetMousePos(); 254 mouse.y += scroll; 255 int set = -1; 256 for (int i = 0; i < (int)pList->m_Items.size(); ++i) 257 { 258 if (mouse.y >= rect.top + m_ItemsYPositions[i] && 259 mouse.y < rect.top + m_ItemsYPositions[i + 1] && 260 // mouse is not over scroll-bar 261 (!scrollbar || !GetScrollBar(0).IsVisible() || 262 mouse.x < GetScrollBar(0).GetOuterRect().left || 263 mouse.x > GetScrollBar(0).GetOuterRect().right)) 264 { 265 set = i; 266 } 267 } 268 269 GUI<int>::SetSetting(this, "hovered_item", set); 270 ScriptEvent("hoverchange"); 271 break; 272 } 273 231 274 case GUIM_LOAD: 232 275 { 233 276 CStr scrollbar_style;