This repository has been archived by the owner on Feb 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
expert975
committed
Oct 15, 2017
1 parent
04e9b9b
commit fc8991c
Showing
7 changed files
with
153 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
local sx, sy = guiGetScreenSize() | ||
local globeTexture = DxTexture("lang/globe2.png") | ||
local color = 0 | ||
local lastTick = 0 | ||
local rootx = sx*0.013020833 --25 | ||
local rooty = sy*0.148148148 --160 | ||
local sizex = sx*0.039062500 --75 | ||
local sizey = sy*0.069444444 --75 | ||
local radius = sizex*.5 | ||
local centerx = sizex*.5 + rootx | ||
local centery = sizey*.5 + rooty | ||
local isRendering = false | ||
local functionToCallOnClick | ||
local Globe = {} | ||
|
||
local function render() | ||
dxDrawImage(rootx, rooty, sizex, sizey, globeTexture, 0, 0, 0, tocolor(color,color,color,255), false) | ||
end | ||
|
||
local function isClickInsideGlobe(button, state, cursorx, cursory) | ||
if button == "left" and state == "up" then | ||
local distance = math.sqrt( | ||
math.pow(centerx - cursorx, 2) | ||
+ math.pow(centery - cursory, 2) | ||
) | ||
local isInside = distance <= radius | ||
if isInside and functionToCallOnClick then | ||
functionToCallOnClick() | ||
end | ||
end | ||
end | ||
|
||
local function fadeIn() | ||
if color < 255 then | ||
local dTime = getTickCount() - lastTick | ||
local controlVar = (256*dTime)/1000 | ||
color = color + controlVar | ||
if color > 255 then | ||
color = 255 | ||
end | ||
lastTick = getTickCount() | ||
else | ||
removeEventHandler("onClientRender", root, fadeIn) | ||
end | ||
end | ||
|
||
function Globe.setFadingIn() | ||
lastTick = getTickCount() | ||
addEventHandler("onClientRender", root, fadeIn) | ||
end | ||
|
||
function Globe.setRendering(shouldRender) | ||
if shouldRender then | ||
addEventHandler("onClientRender", root, render) | ||
addEventHandler("onClientClick", root, isClickInsideGlobe) | ||
Globe.setFadingIn() | ||
else | ||
removeEventHandler("onClientRender", root, render) | ||
removeEventHandler("onClientClick", root, isClickInsideGlobe) | ||
removeEventHandler("onClientRender", root, fadeIn) | ||
end | ||
isRendering = shouldRender | ||
end | ||
|
||
function Globe.getRendering() | ||
return isRendering | ||
end | ||
|
||
function Globe.toggleRendering() | ||
Globe.setRendering(not isRendering) | ||
end | ||
|
||
function Globe.setCallOnClick(functionToCall) | ||
functionToCallOnClick = functionToCall | ||
end | ||
|
||
LanguageGlobeButton = Globe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
local sx, sy = guiGetScreenSize() | ||
local rootx = sx*0.008854167 --17 | ||
local rooty = sy*0.225925926 --244 | ||
local languageComboBox | ||
local languageCodes = {} | ||
|
||
local function setNewLanguage() | ||
local selectedItem = languageComboBox:getSelected() | ||
local languageName = languageComboBox:getItemText(selectedItem) | ||
Language.set(languageCodes[languageName]) | ||
end | ||
|
||
local function createComboBox() | ||
languageComboBox = guiCreateComboBox(rootx, rooty, 100, 20, Language.getCurrentName(), false) | ||
guiComboBoxAdjustHeight(languageComboBox, Language.getCount()) | ||
end | ||
|
||
local function getAvailableLanguages() | ||
for languageIndex, languageCode in ipairs(Language.getAvailable()) do | ||
local languageName = Language.getLanguageNameFromCode(languageCode) | ||
languageCodes[languageName] = languageCode | ||
end | ||
end | ||
|
||
local function populateCombobox() | ||
getAvailableLanguages() | ||
for languageName, languageCode in pairs(languageCodes) do | ||
guiComboBoxAddItem(languageComboBox, languageName) | ||
end | ||
end | ||
|
||
local function showComboBox() | ||
languageComboBox:setVisible(true) | ||
end | ||
|
||
local function hideComboBox() | ||
languageComboBox:setVisible(false) | ||
end | ||
|
||
local function toggleDialog() | ||
if languageComboBox:getVisible() then | ||
hideComboBox() | ||
setNewLanguage() | ||
else | ||
showComboBox() | ||
end | ||
end | ||
|
||
local function attachToButton() | ||
LanguageGlobeButton.setCallOnClick(toggleDialog) | ||
end | ||
|
||
local function createDialog() | ||
createComboBox() | ||
populateCombobox() | ||
hideComboBox() | ||
attachToButton() | ||
end | ||
addEventHandler("onClientResourceStart", resourceRoot, createDialog) | ||
|
||
LanguageSelection = {} | ||
function LanguageSelection.setShowing(shouldShow) | ||
LanguageGlobeButton.setRendering(shouldShow) | ||
if not shouldShow then | ||
languageComboBox:setVisible(false) | ||
end | ||
end |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters