initial commit optionpanel (WORK IN PROGRESS)

This commit is contained in:
Chr1Z93 2022-12-02 01:17:19 +01:00
parent 9fd95fc126
commit 5a71eda9a7
3 changed files with 119 additions and 61 deletions

View File

@ -43,5 +43,10 @@
"Name": "OverlaySmall",
"Type": 0,
"URL": "http://cloud-3.steamusercontent.com/ugc/1745699502804112719/CFFC89BF9FB8439204EE19CF94180EC99450CD38/"
},
{
"Name": "option-gear",
"Type": 0,
"URL": "http://cloud-3.steamusercontent.com/ugc/2026086584372569912/5CB461AEAE2E59D3064D90A776EB86C46081EC78/"
}
]
]

View File

@ -1,65 +1,90 @@
<!-- Default formatting -->
<Defaults>
<Text color="white" fontSize="16"/>
<!-- general Stuff -->
<Text color="white" fontSize="16"/>
<Button tooltipPosition="Left" color="black"/>
<Toggle textColor="#AAAAAA" fontSize="17" isOn="False"/>
<!-- Window title and buttons -->
<HorizontalLayout class="headerLayout" height="75" padding="5"/>
<Button class="headerButton" minWidth="50" preferredWidth="50" flexibleWidth="0" color="clear"/>
<Text class="headerText" minWidth="200" flexibleWidth="100" fontSize="32"/>
<!-- Window layouting -->
<VerticalLayout class="window" active="false" visibility="Admin" width="800" height="780" color="black" outlineSize="1 1" outline="#303030"/>
<Row class="tblRow" preferredHeight="75"/>
</Defaults>
<!-- Buttons in the bottom right of the screen -->
<VerticalLayout
visibility="Admin"
color="black" outlineSize="1 1" outline="#303030"
rectAlignment="LowerRight" width="40" height="200" offsetXY="0 100">
<Button icon="cthulhu" tooltipPosition="Left" tooltip="Campaigns"
onClick="onClick_toggleUi(Campaigns)"
color="black"/>
<Button icon="dark-cult" tooltipPosition="Left" tooltip="Standalone Scenarios"
onClick="onClick_toggleUi(Standalone Scenarios)"
color="black"/>
<Button icon="yog-sothoth" tooltipPosition="Left" tooltip="Extras"
onClick="onClick_toggleUi(Extras)"
color="black"/>
<Button icon="elder-sign" tooltipPosition="Left" tooltip="Investigators"
onClick="onClick_toggleUi(Investigators)"
color="black"/>
<Button icon="devourer" tooltipPosition="Left" tooltip="Community Content"
onClick="onClick_toggleUi(Community Content)"
color="black"/>
<?ignore
<Button icon="download" tooltipPosition="Left" tooltip="ArkhamDB Deck Importer"
onClick="onClick_toggleUi(Deck Importer)"
color="black"/>
?>
color="black"
outlineSize="1 1"
outline="#303030"
rectAlignment="LowerRight"
width="40"
height="240"
offsetXY="-1 70">
<Button color="#000000" icon="cthulhu" tooltip="Campaigns" onClick="onClick_toggleUi(Campaigns)"/>
<Button color="#000000" icon="dark-cult" tooltip="Standalone Scenarios" onClick="onClick_toggleUi(Standalone Scenarios)"/>
<Button color="#000000" icon="yog-sothoth" tooltip="Extras" onClick="onClick_toggleUi(Extras)"/>
<Button color="#000000" icon="elder-sign" tooltip="Investigators" onClick="onClick_toggleUi(Investigators)"/>
<Button color="#000000" icon="devourer" tooltip="Community Content" onClick="onClick_toggleUi(Community Content)"/>
<Button color="#000000" icon="option-gear" tooltip="Option Panel" onClick="onClick_toggleUi(Option Panel)"/>
<!--<Button icon="download" tooltip="ArkhamDB Deck Importer" onClick="onClick_toggleUi(Deck Importer)"/> -->
</VerticalLayout>
<!-- allowDragging="true" returnToOriginalPositionWhenReleased="false" -->
<VerticalLayout
id="load_ui"
active="false"
visibility="Admin"
width="800" height="780"
color="black" outlineSize="1 1" outline="#303030">
<HorizontalLayout minHeight="50" preferredHeight="50" flexibleHeight="0">
<Button icon="refresh"
tooltip="Refresh List" tooltipPosition="Right"
onClick="onClick_refreshList"
minWidth="50" preferredWidth="50" flexibleWidth="0" color="black"/>
<Text id="title" minWidth="200" flexibleWidth="100" fontSize="36">Loadable Items</Text>
<Button icon="close" tooltip="Close" tooltipPosition="Left"
onClick="onClick_toggleUi(Hidden)"
minWidth="50" preferredHeight="50" flexibleWidth="0" color="black"/>
<!-- Basic UI that will be replaced based on title -->
<VerticalLayout id="load_ui" class="window">
<HorizontalLayout class="headerLayout">
<Button class="headerButton" icon="refresh" tooltip="Refresh List" tooltipPosition="Right" onClick="onClick_refreshList"/>
<Text id="title" class="headerText">Loadable Items</Text>
<Button class="headerButton" icon="close" tooltip="Close" onClick="onClick_toggleUi(Hidden)"/>
</HorizontalLayout>
<VerticalScrollView
color="transparent" minHeight="100" flexibleHeight="100">
<VerticalScrollView color="transparent" minHeight="100" flexibleHeight="100">
<Panel id="ui_update_height" height="24">
<VerticalLayout id="ui_update_point">
<VerticalLayout id="ui_update_point" padding="10">
<Text>Please refresh to see available items.</Text>
</VerticalLayout>
</Panel>
</VerticalScrollView>
<Panel color="rgb(0,0,0)" minHeight="50" preferredHeight="50" flexibleHeight="0" active="true">
<Button id="load_buttion" active="false" onClick="onClick_load">Load:</Button>
<HorizontalLayout id="progress_display" active="true">
<Panel color="rgb(0,0,0)" minHeight="50" preferredHeight="50" flexibleHeight="0">
<Button id="load_button" active="false" onClick="onClick_load">Load:</Button>
<HorizontalLayout id="progress_display">
<ProgressBar id="download_progress" percentage="0" color="#000000" fillImageColor="#333333"/>
<Button onClick="onClick_cancel" active="false">Cancel</Button>
</HorizontalLayout>
</Panel>
</VerticalLayout>
<!-- Option Panel -->
<VerticalLayout id="optionPanel" class="window">
<HorizontalLayout class="headerLayout">
<Button class="headerButton" icon="refresh" tooltip="Default Settings" tooltipPosition="Right" onClick="onClick_defaultSettings"/>
<Text class="headerText">Option Panel</Text>
<Button class="headerButton" icon="close" tooltip="Close" onClick="onClick_toggleUi(Hidden)"/>
</HorizontalLayout>
<VerticalScrollView color="transparent" minHeight="100" flexibleHeight="100">
<TableLayout padding="20" cellPadding="10" cellSpacing="10">
<Row class="tblRow">
<Cell><Toggle id="toggle1" onValueChanged="onClick_toggleOption(1)">Toggle Text 1</Toggle></Cell>
<Cell><Toggle id="toggle2" onValueChanged="onClick_toggleOption(2)">Toggle Text 2</Toggle></Cell>
</Row>
<Row class="tblRow">
<Cell><Toggle id="toggle3" onValueChanged="onClick_toggleOption(3)">Toggle Text 3</Toggle></Cell>
<Cell><Toggle id="toggle4" onValueChanged="onClick_toggleOption(4)">Toggle Text 4</Toggle></Cell>
</Row>
<Row class="tblRow">
<Cell><Toggle id="toggle5" onValueChanged="onClick_toggleOption(5)">Toggle Text 5</Toggle></Cell>
<Cell><Toggle id="toggle6" onValueChanged="onClick_toggleOption(6)">Toggle Text 6</Toggle></Cell>
</Row>
<Row class="tblRow">
<Cell><Toggle id="toggle7" onValueChanged="onClick_toggleOption(7)">Toggle Text 7</Toggle></Cell>
<Cell><Toggle id="toggle8" onValueChanged="onClick_toggleOption(8)">Toggle Text 8</Toggle></Cell>
</Row>
</TableLayout>
</VerticalScrollView>
<Panel color="rgb(0,0,0)" minHeight="50" preferredHeight="50" flexibleHeight="0">
<Button onClick="onClick_applySettings" color="#888888" fontSize="25">Apply Settings</Button>
</Panel>
</VerticalLayout>

View File

@ -558,14 +558,10 @@ local source_repo = 'https://raw.githubusercontent.com/seth-sced/loadable-object
local library = nil
local request_obj
function onClick_toggleUi(player, window)
toggle_ui(window)
end
function onClick_refreshList()
local request = WebRequest.get(source_repo .. '/library.json', completed_list_update)
request_obj = request
startLuaCoroutine(Global, 'my_coroutine')
startLuaCoroutine(Global, 'downloadCoroutine')
end
function onClick_select(player, params)
@ -573,7 +569,7 @@ function onClick_select(player, params)
local url = source_repo .. '/' .. params.url
local request = WebRequest.get(url, function (request) complete_obj_download(request, params) end )
request_obj = request
startLuaCoroutine(Global, 'my_coroutine')
startLuaCoroutine(Global, 'downloadCoroutine')
end
function onClick_load()
@ -581,18 +577,50 @@ function onClick_load()
UI.hide('load_button')
end
function toggle_ui(title)
UI.hide('load_ui')
if UI.getValue('title') == title or title == 'Hidden' then
UI.setValue('title', 'Hidden')
function onClick_defaultSettings()
print("Dummy: Load default settings")
end
local optionPanel = {}
function onClick_toggleOption(_, id)
local state = self.UI.getAttribute("toggle" .. id, "isOn")
-- flip state (and handle stupid "False" value)
if state == "False" then
state = true
else
state = false
end
self.UI.setAttribute("toggle" .. id, "isOn", state)
optionPanel[id] = state
print("Option no. " .. id .. ": " .. tostring(optionPanel[id]))
end
function onClick_applySettings()
print("Dummy: Apply settings")
end
function onClick_toggleUi(_, title)
UI.hide('optionPanel')
UI.hide('load_ui')
-- when same button is clicked or close window button is pressed, don't open UI
if UI.getValue('title') ~= title and title ~= 'Hidden' then
UI.setValue('title', title)
update_window_content(title)
UI.show('load_ui')
if title == "Option Panel" then
UI.show('optionPanel')
else
update_window_content(title)
UI.show('load_ui')
end
else
UI.setValue('title', "Hidden")
end
end
function my_coroutine()
function downloadCoroutine()
while request_obj do
UI.setAttribute('download_progress', 'percentage', request_obj.download_progress * 100)
coroutine.yield(0)