Skip to content

Commit

Permalink
Menu reworks, and translations
Browse files Browse the repository at this point in the history
  • Loading branch information
EvaisaDev committed Jun 14, 2024
1 parent 6ebc183 commit 1e2bc71
Show file tree
Hide file tree
Showing 10 changed files with 1,578 additions and 704 deletions.
Binary file modified evaisa.mp/bin/luasteam.dll
Binary file not shown.
Binary file modified evaisa.mp/bin/luasteam.pdb
Binary file not shown.
Binary file added evaisa.mp/files/gfx/ui/9piece_white.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
137 changes: 137 additions & 0 deletions evaisa.mp/files/gfx/ui/9piece_white.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
<Sprite filename="mods/evaisa.mp/files/gfx/ui/9piece_white.png" >
<!--Top Left-->
<RectAnimation
name="tl"
pos_x="0"
pos_y="0"
frame_width="3"
frame_height="3"
has_offset="0"
frame_count="1"
frame_wait="0.2"
frames_per_row="1"
shrink_by_one_pixel="0"
loop="0" >
</RectAnimation>
<!--Top Center-->
<RectAnimation
name="tc"
pos_x="3"
pos_y="0"
frame_width="3"
frame_height="3"
has_offset="0"
frame_count="1"
frame_wait="0.2"
frames_per_row="1"
shrink_by_one_pixel="0"
loop="0" >
</RectAnimation>
<!--Top Right-->
<RectAnimation
name="tr"
pos_x="6"
pos_y="0"
frame_width="3"
frame_height="3"
has_offset="0"
frame_count="1"
frame_wait="0.2"
frames_per_row="1"
shrink_by_one_pixel="0"
loop="0" >
</RectAnimation>

<!--Middle Left-->
<RectAnimation
name="lc"
pos_x="0"
pos_y="3"
frame_width="3"
frame_height="3"
has_offset="0"
frame_count="1"
frame_wait="0.2"
frames_per_row="1"
shrink_by_one_pixel="0"
loop="0" >
</RectAnimation>

<!--Middle Center-->
<RectAnimation
name="c"
pos_x="3"
pos_y="3"
frame_width="3"
frame_height="3"
has_offset="0"
frame_count="1"
frame_wait="0.2"
frames_per_row="1"
shrink_by_one_pixel="0"
loop="0" >
</RectAnimation>

<!--Middle Right-->
<RectAnimation
name="rc"
pos_x="6"
pos_y="3"
frame_width="3"
frame_height="3"
has_offset="0"
frame_count="1"
frame_wait="0.2"
frames_per_row="1"
shrink_by_one_pixel="0"
loop="0" >
</RectAnimation>

<!--Bottom Left-->
<RectAnimation
name="bl"
pos_x="0"
pos_y="6"
frame_width="3"
frame_height="3"
has_offset="0"
frame_count="1"
frame_wait="0.2"
frames_per_row="1"
shrink_by_one_pixel="0"
loop="0" >
</RectAnimation>

<!--Bottom Center-->
<RectAnimation
name="bc"
pos_x="3"
pos_y="6"
frame_width="3"
frame_height="3"
has_offset="0"
frame_count="1"
frame_wait="0.2"
frames_per_row="1"
shrink_by_one_pixel="0"
loop="0" >
</RectAnimation>

<!--Bottom Right-->
<RectAnimation
name="br"
pos_x="6"
pos_y="6"
frame_width="3"
frame_height="3"
has_offset="0"
frame_count="1"
frame_wait="0.2"
frames_per_row="1"
shrink_by_one_pixel="0"
loop="0" >
</RectAnimation>



</Sprite>
3 changes: 3 additions & 0 deletions evaisa.mp/files/scripts/chat_ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ chat_gui = chat_gui or GuiCreate()

GuiStartFrame(chat_gui)

if (IsPaused()) then
return
end



Expand Down
1 change: 1 addition & 0 deletions evaisa.mp/files/scripts/game_functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ game_funcs = {
local r, g, b = color.r, color.g, color.b
local a = 1
GuiColorSetForNextWidget(marker_gui, r / 255, g / 255, b / 255, a)
GuiZSetForNextWidget(marker_gui, -100000)

GuiImage(marker_gui, new_id(), marker_x, marker_y, marker_image, 1, 1, 1)
--GuiText(gui, marker_x / 2, marker_y / 2, "o")
Expand Down
209 changes: 209 additions & 0 deletions evaisa.mp/files/scripts/gui_utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -602,4 +602,213 @@ function CustomTooltip(gui, callback, z, x_offset, y_offset )
GuiLayoutEnd( gui );
GuiLayoutEndLayer( gui );
end
end

function Gui9Piece(gui, id_func, x, y, width, height, alpha, z_index, image_sprite, piece_size)
-- top left
GuiZSetForNextWidget(gui, z_index)
GuiImage(gui, id_func(), x, y, image_sprite, alpha, 1, 1, 0, 1, "tl")
-- top right
GuiZSetForNextWidget(gui, z_index)
GuiImage(gui, id_func(), x + width - piece_size, y, image_sprite, alpha, 1, 1, 0, 1, "tr")
-- bottom left
GuiZSetForNextWidget(gui, z_index)
GuiImage(gui, id_func(), x, y + height - piece_size, image_sprite, alpha, 1, 1, 0, 1, "bl")
-- bottom right
GuiZSetForNextWidget(gui, z_index)
GuiImage(gui, id_func(), x + width - piece_size, y + height - piece_size, image_sprite, alpha, 1, 1, 0, 1, "br")
-- top
GuiZSetForNextWidget(gui, z_index)
GuiImage(gui, id_func(), x + piece_size, y, image_sprite, alpha, (width - piece_size * 2) / piece_size, 1, 0, 1, "tc")
-- bottom
GuiZSetForNextWidget(gui, z_index)
GuiImage(gui, id_func(), x + piece_size, y + height - piece_size, image_sprite, alpha, (width - piece_size * 2) / piece_size, 1, 0, 1, "bc")
-- left
GuiZSetForNextWidget(gui, z_index)
GuiImage(gui, id_func(), x, y + piece_size, image_sprite, alpha, 1, (height - piece_size * 2) / piece_size, 0, 1, "lc")
-- right
GuiZSetForNextWidget(gui, z_index)
GuiImage(gui, id_func(), x + width - piece_size, y + piece_size, image_sprite, alpha, 1, (height - piece_size * 2) / piece_size, 0, 1, "rc")
-- center
GuiZSetForNextWidget(gui, z_index)
GuiImage(gui, id_func(), x + piece_size, y + piece_size, image_sprite, alpha, (width - piece_size * 2) / piece_size, (height - piece_size * 2) / piece_size, 0, 1, "c")
end

local button_stack = {}
function GuiTextButton(gui, id_func, x, y, text, z_index, line_spacing, color_r, color_g, color_b, color_a, max_width, tooltip_func)
color_r = color_r or 1
color_g = color_g or 1
color_b = color_b or 1
color_a = color_a or 1
max_width = max_width or 10000
local was_hovered = false
local id = id_func()
if(button_stack[id] == nil)then
button_stack[id] = {}
else
was_hovered = button_stack[id].hovered
end
local any_was_hovered = false
local any_was_clicked = false
local any_was_right_clicked = false

local index = 0
local last_x = 0
if type(text) == "table" then
for i, txt in ipairs(text)do
local str = txt.text
local color = txt.color or nil

local x_offset = last_x or 0

for line in str:gmatch("[^\r\n]+") do
local text_width, text_height = GuiGetTextDimensions(gui, line)
if(was_hovered)then
GuiColorSetForNextWidget(gui, 255 / 255, 255 / 255, 178 / 255, 1)
else
if color then
GuiColorSetForNextWidget(gui, color[1], color[2], color[3], color[4])
else
GuiColorSetForNextWidget(gui, color_r, color_g, color_b, color_a)
end
end
GuiZSetForNextWidget(gui, z_index)
local offset = index * (text_height + (line_spacing or 0))

if(x_offset ~= 0 and x + x_offset > max_width)then
index = index + 1
x_offset = 0
offset = index * (text_height + (line_spacing or 0))
end

GuiButton(gui, id_func(), x + x_offset, y + offset, line)
if(tooltip_func)then
tooltip_func()
end

last_x = x + text_width

local clicked, right_clicked, hovered = GuiGetPreviousWidgetInfo(gui)

if(clicked)then
any_was_clicked = true
end
if(right_clicked)then
any_was_right_clicked = true
end
if(hovered)then
any_was_hovered = true
end

x_offset = 0


index = index + 1
end
index = index - 1

end
else
for line in text:gmatch("[^\r\n]+") do
local text_width, text_height = GuiGetTextDimensions(gui, line)
if(was_hovered)then
GuiColorSetForNextWidget(gui, 255 / 255, 255 / 255, 178 / 255, 1)
else
GuiColorSetForNextWidget(gui, color_r, color_g, color_b, color_a)
end
GuiZSetForNextWidget(gui, z_index)
local offset = index * (text_height + (line_spacing or 0))
GuiButton(gui, id_func(), x, y + offset, line)
if(tooltip_func)then
tooltip_func()
end
local clicked, right_clicked, hovered = GuiGetPreviousWidgetInfo(gui)

if(clicked)then
any_was_clicked = true
end
if(right_clicked)then
any_was_right_clicked = true
end
if(hovered)then
any_was_hovered = true
end

index = index + 1
end
end

button_stack[id].hovered = any_was_hovered
button_stack[id].clicked = any_was_clicked
button_stack[id].right_clicked = any_was_right_clicked

return any_was_clicked, any_was_clicked, any_was_hovered
end

function GuiTextMultiline(gui, x, y, text, z_index, line_spacing, color_r, color_g, color_b, color_a, max_width, tooltip_func)
-- guitext with multiline support
color_r = color_r or 1
color_g = color_g or 1
color_b = color_b or 1
color_a = color_a or 1
max_width = max_width or 10000

local index = 0
local last_x = 0
if type(text) == "table" then
for i, txt in ipairs(text)do
local str = txt.text
local color = txt.color or nil

local x_offset = last_x or 0

for line in str:gmatch("[^\r\n]+") do
local text_width, text_height = GuiGetTextDimensions(gui, line)

if color then
GuiColorSetForNextWidget(gui, color[1], color[2], color[3], color[4])
else
GuiColorSetForNextWidget(gui, color_r, color_g, color_b, color_a)
end

GuiZSetForNextWidget(gui, z_index)
local offset = index * (text_height + (line_spacing or 0))

if(x_offset ~= 0 and x + x_offset > max_width)then
index = index + 1
x_offset = 0
offset = index * (text_height + (line_spacing or 0))
end

GuiText(gui, x + x_offset, y + offset, line)
if(tooltip_func)then
tooltip_func()
end

last_x = x + text_width

x_offset = 0


index = index + 1
end
index = index - 1

end
else
for line in text:gmatch("[^\r\n]+") do
local text_width, text_height = GuiGetTextDimensions(gui, line)

GuiColorSetForNextWidget(gui, color_r, color_g, color_b, color_a)

GuiZSetForNextWidget(gui, z_index)
local offset = index * (text_height + (line_spacing or 0))
GuiText(gui, x, y + offset, line)
if(tooltip_func)then
tooltip_func()
end

index = index + 1
end
end
end
Loading

0 comments on commit 1e2bc71

Please sign in to comment.