Skip to content

Commit

Permalink
Q7
Browse files Browse the repository at this point in the history
  • Loading branch information
mhnaufal committed Apr 22, 2024
1 parent 6fc1c18 commit 007c121
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 8 deletions.
40 changes: 40 additions & 0 deletions Q7/test.lua
Original file line number Diff line number Diff line change
@@ -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
14 changes: 14 additions & 0 deletions Q7/test.otmod
Original file line number Diff line number Diff line change
@@ -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()
37 changes: 37 additions & 0 deletions Q7/test.otui
Original file line number Diff line number Diff line change
@@ -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()
Binary file added Q7/test/test.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 6 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Binary file added q7.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 007c121

Please sign in to comment.