diff --git a/Q7/test.lua b/Q7/test.lua new file mode 100644 index 0000000..1d39b49 --- /dev/null +++ b/Q7/test.lua @@ -0,0 +1,40 @@ +testButton = nil +testWindow = nil + + +function init() + -- Top left icon button + testButton = modules.client_topmenu.addLeftToggleButton('testButton', tr('Test Button'), + '/test/test/test', closing) + testButton:setOn(false) + + testWindow = g_ui.displayUI('test') -- initiate the window ui + testWindow:setVisible(false) -- dont shoe the window ui yet + + allTabs = testWindow:recursiveGetChildById('allTabs') + allTabs:setContentWidget(testWindow:getChildById('optionsTabContent')) +end + +function terminate() + testButton:destroy() + testWindow:destroy() +end + +function closing() + if testButton:isOn() then + testWindow:setVisible(false) + testButton:setOn(false) + else + testWindow:setVisible(true) + testButton:setOn(true) + end +end + + +function move() + testButton:setPositionX(1) -- I'm lost here :) +end + +function onMiniWindowClose() + testButton:setOn(false) +end diff --git a/Q7/test.otmod b/Q7/test.otmod new file mode 100644 index 0000000..c768c1b --- /dev/null +++ b/Q7/test.otmod @@ -0,0 +1,14 @@ +Module + name: test + description: test + author: mhnaufal + website: - + version: 1 + + autoload: true + autoload-priority: 1000 + sandboxed: true + dependencies: [ game_interface ] + scripts: [ test.lua ] + @onLoad: init() + @onUnload: terminate() \ No newline at end of file diff --git a/Q7/test.otui b/Q7/test.otui new file mode 100644 index 0000000..3985dc4 --- /dev/null +++ b/Q7/test.otui @@ -0,0 +1,37 @@ +MainWindow + id: testMain + !text: tr('test') + size: 350 300 + @onEscape: modules.test.closing() + + TabBar + id: allTabs + anchors.top: parent.top + anchors.right: parent.right + anchors.bottom: parent.bottom + anchors.left: parent.left + + Panel + id: optionsTabContent + anchors.top: allTabs.top + anchors.left: allTabs.left + anchors.right: allTabs.right + anchors.bottom: allTabs.bottom + margin-top: 20 + margin-bottom: 20 + + Button + id: MovingButton + !text: tr('MovingButton') + width: 150 + anchors.left: parent.left + anchors.top: parent.top + @onClick: modules.test.cake() + + Button + id: closeButton + !text: tr('Close') + width: 200 + anchors.left: parent.left + anchors.bottom: parent.bottom + @onClick: modules.test.closing() \ No newline at end of file diff --git a/Q7/test/test.png b/Q7/test/test.png new file mode 100644 index 0000000..5a8265d Binary files /dev/null and b/Q7/test/test.png differ diff --git a/README.md b/README.md index 223de96..388cd57 100644 --- a/README.md +++ b/README.md @@ -6,29 +6,27 @@ ## Questions -Below are my try to solve the questions. +Below are my try to solve the questions. Even though I'm only finish some of them, I have tried my best 😁 ### Q1-Q4 **Commit:** [text](link) ### Q5 -**Commit:** [text](link) - -**Video:** [text](link) +_Sorry but I didn't manage to solve this_ ### Q6 -**Commit:** [text](link) - -**Video:** [text](link) +_Sorry but I didn't manage to solve this_ ### Q7 **Commit:** [text](link) -**Video:** [text](link) +**Video:** ![Q7](q7.gif) ## Helpers 1. https://stackoverflow.com/questions/22220512/check-for-null-in-stdshared-ptr 2. https://tylerneylon.com/a/learn-lua/ 3. https://www.youtube.com/watch?v=iMacxZQMPXs +4. This one really helps me: https://github.com/edubart/otclient/issues/1203 (even I made a comment there!) +5. https://otland.net/threads/tutorial-mods-creating-modules-with-extended-opcode.270062/ (Thanks) diff --git a/q7.gif b/q7.gif new file mode 100644 index 0000000..3ae768f Binary files /dev/null and b/q7.gif differ