---
--- Generated by EmmyLua(https://github.com/EmmyLua)
--- Created by DY.
--- DateTime: 2020/8/25 10:22
---

local GeneralSettingCfg = ImportScript("ugc_common/script/cases/general_setting/config.lua").GeneralSettingCfg

UI_GENERAL_SETTING = "GeneralSettingUi";
local Ui = Ui or class(UI_GENERAL_SETTING, LUiBase);
_G.UI_GENERAL_SETTING = UI_GENERAL_SETTING;

function Ui:ctor()
    self.m_bOpen = false
    self.m_szName = UI_GENERAL_SETTING

    self.m_szWindowName = util.a2u8("通用设置");
    self.m_szThemeBackground = util.a2u8("主题设置");
    self.m_szBackgroundColor = util.a2u8("背景颜色");
    self.m_szCameraResolution = util.a2u8("拍照分辨率");

    self.m_tbEvnNames = nil
    self.m_tbEvnPaths = nil
    self.m_tbBackgroundZone = nil
    self.m_tbCameraResolution = nil
    self.m_tbBackgroundColor = {0.5,0.5,0.5,0.5}
    self.m_nCurEvnTexture = 1
    self.m_nCurZone = 1
    self.m_nCurResolution = 1
end

function Ui:dtor()
end

function Ui:Init()
end

function Ui:UnInit()

end

function Ui:OnOpen()
    self.m_tbEvnNames, self.m_tbEvnPaths = GeneralSettingCfg:GetEvnName_Path()
    self.m_tbBackgroundZone = GeneralSettingCfg:GetBackgroundZone()
    self.m_tbCameraResolution = GeneralSettingCfg:GetCameraResolution()
end

function Ui:OnClose()
end

function Ui:GameTick()
end

function Ui:GameDraw()
    ImGui.SetNextWindowSize(ImVec2(850,380),ImGuiCond_.ImGuiCond_FirstUseEver)
    _, self.m_bOpen = ImGui.Begin(self.m_szWindowName, self.m_bOpen);
    --_,self.bResolution =ImGui.MenuItem("拍照分辨率",nil,self.bResolution);

    -- 主题设置
    if ImGui.BeginCombo(self.m_szThemeBackground, self.m_tbEvnNames[self.m_nCurEvnTexture], 0) then
        for idx, char in ipairs(self.m_tbEvnNames) do
            local bSelected = idx == self.m_nCurEvnTexture;
            if ImGui.Selectable(char, bSelected) then
                self.m_nCurEvnTexture = idx
                KLPlatformNative:SetEvnTexture(self.m_tbEvnPaths[idx])
            end
        end
        ImGui.EndCombo();
    end
    -- 背景颜色设置
    if ImGui.BeginCombo(self.m_szBackgroundColor, self.m_tbBackgroundZone[self.m_nCurZone], 0) then
        for idx, char in ipairs(self.m_tbBackgroundZone) do
            local bSelected = idx == self.m_nCurZone;
            if ImGui.Selectable(char, bSelected) then
                self.m_nCurZone = idx
            end
        end
        ImGui.EndCombo();
    end
    if ImGui.ColorEdit4("Color Picker",self.m_tbBackgroundColor) then
        KLPlatformNative:SetColor(self.m_nCurZone,self.m_tbBackgroundColor,#self.m_tbBackgroundColor)
    end

    if ImGui.BeginCombo(self.m_szCameraResolution, self.m_tbCameraResolution[self.m_nCurResolution], 0) then
        for idx, char in pairs(self.m_tbCameraResolution) do
            local bSelected = idx == self.m_nCurResolution;
            if ImGui.Selectable(char, bSelected) then
                self.m_nCurResolution = idx
                KLPlatformNative:SetResolution(self.m_nCurResolution)
            end
        end
        ImGui.EndCombo();
    end

    ImGui.End()
end

UiInst = Ui:new();