#include "common_components.lua" #include "ui/ui_extensions.lua" #include "photomode_logic.lua" function drawPhotomodeHint() local bgWidth = 1800 local bgHeight = 58 local padding = 20 UiPush() UiColorFilter(1.0, 1.0, 1.0, 1) UiPush() UiColor(1, 1, 1, 1) UiImageBox("common/rect_c#000_o0.60_cr9.png", bgWidth, bgHeight, 10, 10) UiPop() UiPush() local hints = {} local exitText = "loc@UI_BUTTON_EXIT" local exitIcon = "" if GetString("game.input.curdevice") == "mouse" then hints = { { icon = Ui.ActionIcons.lmb, text="loc@FOCUS" }, { icon = Ui.ActionIcons.wasd, text="loc@MOVE_CAMERA" }, { icon = Ui.ActionIcons.rmb, text="loc@ROTATE_CAMERA" }, { icon = Ui.ActionIcons.mmb, text="loc@TILT_CAMERA" }, { icon = Ui.ActionIcons.enter, text="loc@TAKE_A_PHOTO" }, { icon = Ui.ActionIcons.space, text="loc@SHOW_SETTINGS" }, { icon = Ui.ActionIcons.wheel, text="loc@ZOOM_IN_OUT" }, } exitIcon = Ui.ActionIcons["menu:menu_cancel"] else hints = { { icon = Ui.ActionIcons["menu:interact"], text="loc@FOCUS" }, { icon = Ui.ActionIcons["menu:gamepad_left_stick"], text="loc@MOVE_CAMERA" }, { icon = Ui.ActionIcons["menu:gamepad_right_stick"], text="loc@ROTATE_CAMERA" }, { icon = Ui.ActionIcons["menu:menu_prev"] / Ui.ActionIcons["menu:menu_next"], text="loc@TILT_CAMERA" }, { icon = Ui.ActionIcons["menu:menu_accept"], text="loc@TAKE_A_PHOTO" }, { icon = Ui.ActionIcons["menu:mmb"], text="loc@SHOW_SETTINGS" }, { icon = Ui.ActionIcons["menu:rmb"] / Ui.ActionIcons["menu:lmb"], text="loc@ZOOM_IN_OUT" }, } exitIcon = Ui.ActionIcons["menu:menu_cancel"] end -- on consoles we cannot take screenshot. But instead we can hide UI if not IsRunningOnPC() and not IsRunningOnMac() then hints[5].text = "loc@HIDE_UI" end local iconIndent = 4 local hintsIndent = 15 UiPush() UiAlign("middle left") UiTranslate(padding, bgHeight / 2) local combinedOffset = 0 for i=1,#hints do UiColor(1, 1, 1, 1) UiFont("regular.ttf", 27) UiPush() UiTranslate(0, -hints[i].icon.h / 2) hints[i].icon:draw() UiPop() UiTranslate(hints[i].icon.w + iconIndent, 0) combinedOffset = combinedOffset + hints[i].icon.w + iconIndent UiColor(1, 1, 1, 0.8) UiFont("regular.ttf", 27) local offset = UiGetTextSize(GetTranslatedStringByKey(hints[i].text)) UiText(hints[i].text) UiTranslate(offset + hintsIndent, 0) combinedOffset = combinedOffset + offset + hintsIndent end UiPop() UiPush() UiTranslate(bgWidth - padding, bgHeight / 2) UiAlign("middle right") UiColor(1, 1, 1, 0.8) UiFont("regular.ttf", 27) UiText(exitText) local offset = UiGetTextSize(GetTranslatedStringByKey(exitText)) UiColor(1, 1, 1, 1) UiFont("regular.ttf", 27) UiTranslate(-(offset + iconIndent), 0) UiPush() UiAlign("top left") UiTranslate(-exitIcon.w, -exitIcon.h / 2) exitIcon:draw() UiPop() UiPop() UiPop() UiPop() end PhotomodeOptions.backGround = { w = 12.0, h = 860.0, draw = function(self) UiPush() UiColor(1, 1, 1, 1) UiImageBox("common/rect_c#525252_o1.00_cr4.png", self.w, self.h, 4, 4) UiPop() end, } PhotomodeOptions.thumb = { w = 8.0, h = 184.0, draw = function(self) UiPush() UiTranslate(2.0, 2.0) UiColor(1, 1, 1, 1) UiImageBox("common/rect_c#ffffff_o1.00_cr3.png", self.w, self.h, 3, 3) UiPop() end, } PhotomodeOptions.scrollBar = UiCreateScrollBar(PhotomodeOptions.thumb, PhotomodeOptions.backGround) PhotomodeOptions.scrollBar.itemsPadding = 10 function drawPhotomodeOptions() -- draw frame F604_1433_options if InputReleased("lmb") then setActiveSlider(nil) end UiPush() UiColorFilter(1.0, 1.0, 1.0, 1) UiPush() UiColor(1, 1, 1, 1) UiImageBox("common/rect_c#000_o0.55_cr8.png", 840, 390, 8, 8) UiPop() UiPush() UiTranslate(20.0, 20.0) UiList(800, 823.0, PhotomodeOptions.listItems, PhotomodeOptions.scrollBar) UiPop() UiPop() end local function clamp_to_range(value, min, max) return (value % (max - min)) + min end local function format_angle(value) return string.format("%.1f°", value) end function drawPhotomodePositionInfo() if not PhotomodeOptions.showPositionInfo then return end local hints = { {title = GetTranslatedStringByKey("HEIGHT"), value = " " .. PhotomodeOptions.heightValue .. "m", max = " 9999m"}, {title = GetTranslatedStringByKey("SCALE"), value = " x" .. PhotomodeOptions.scaleValue, max = " 000"}, {title = GetTranslatedStringByKey("UI_CREATIVE_PITCH"), value = " " .. format_angle(PhotomodeOptions.pitchValue), max=" 000.0°"}, {title = GetTranslatedStringByKey("YAW"), value = " " .. format_angle(clamp_to_range(PhotomodeOptions.yawValue, -180, 180)), max=" 0000.0°"}, {title = GetTranslatedStringByKey("UI_CREATIVE_ROLL"), value = " " .. format_angle(PhotomodeOptions.rollValue), max=" 000.0°"} } -- draw frame F609_1839_stats UiPush() local w = 0 UiFont("regular.ttf", 27) for index, hint in pairs(hints) do local title_width, _ = UiGetTextSize(hint.title) local max_value_width, _ = UiGetTextSize(hint.max) hint.position = w + title_width w = w + title_width + max_value_width + 4 if index < #hints then w = w + 33 end end UiColorFilter(1.0, 1.0, 1.0, 0.8999999761581421) UiTranslate((UiWidth() - (w + 24))/2, 0) UiPush() UiColor(1, 1, 1, 1) UiImageBox("common/rect_c#686868_o0.40_cr9.png", w + 24, 46.0, 10, 10) UiPop() for _, hint in pairs(hints) do UiPush() UiTranslate(12 + hint.position, 13.123976898193405) UiColor(1.0, 1.0, 1.0, 1) UiAlign("right top") UiTranslate(-2, 0) UiText(hint.title) UiTranslate(4, 0) UiAlign("left top") UiText(hint.value) UiPop() end UiPop() end function drawGrid() -- draw frame F609_1846_photomode_grid UiPush() UiColorFilter(1.0, 1.0, 1.0, 1) UiPush() UiColor(1, 1, 1, 1) UiTranslateToScreenCenter() UiTranslateToScreenMiddle(-34 / 2, -34 / 2) UiImage("common/photomode_aim_icon.png") UiPop() UiPush() UiColor(1, 1, 1, 1) if PhotomodeOptions.showGrid then local canvas = UiCanvasSize() UiScale(canvas.w / 1920, canvas.h / 1080) UiImage("common/photomode_grid.png") end UiPop() UiTranslate(0, 816.0) drawPhotomodePositionInfo() UiPop() end function drawPhotomode() UiPush() UiAlign("top left") UiColorFilter(1.0, 1.0, 1.0, 1) drawGrid() UiTranslate(60, 980) UiTranslate(0.0, -910.0) if PhotomodeOptions.showOptions then drawPhotomodeOptions() end UiPop() UiPush() UiTranslateToScreenBottomEdge(60, -100) drawPhotomodeHint() UiPop() end