Skip to content

Commit

Permalink
usage tip
Browse files Browse the repository at this point in the history
  • Loading branch information
x2605 committed Sep 6, 2020
1 parent e96a22b commit b6a4803
Show file tree
Hide file tree
Showing 10 changed files with 154 additions and 17 deletions.
13 changes: 13 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
---------------------------------------------------------------------------------------------------
Version: 0.1.2
Date: 2020-09-06

Changes:
- Now return values in tracking list can be copied.
- Added "Usage Tips" menu in "Helper" tab.
- Fixed unable to right-click in "Variable trace" if there is nothing.

Info:
- In new "Usage Tips", I wrote tips I forgot to write before, and introduced a trick to use global table of map as space for memo.


---------------------------------------------------------------------------------------------------
Version: 0.1.1
Date: 2020-09-05
Expand Down
8 changes: 8 additions & 0 deletions data.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ data:extend{
mipmap_count = 1,
scale = 0.5
},
{
type = "font",
name = "var-outline-gvv-mod",
from = "default-bold",
size = 14,
border = true,
border_color = {}
},
}

local default_gui = data.raw['gui-style'].default
Expand Down
2 changes: 1 addition & 1 deletion info.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gvv",
"version": "0.1.1",
"version": "0.1.2",
"title": "Lua API global Variable Viewer (gvv)",
"author": "x2605",
"contact": "",
Expand Down
35 changes: 28 additions & 7 deletions locale/en/gvv.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ remove-checked-button=Remove checked tracking entries
check-for-remove=Check and click __1__ button at top side to remove
show_na=Show n/a
show_func=Show method
obj-list-tooltip=Right click to remove
right-to-select-all=Right click to select all
obj-list-tooltip=Right-click to remove
right-to-select-all=Right-click to select all
input-code=Input code to run in variable trace
confirm-input-code=Input
right-to-copy-code=Right click to copy
right-to-copy-code=Right-click to copy
copy-code=Copy code of a tracking entry
close-main-tooltip=Close (__CONTROL__toggle-main-frame_gvv-mod__)

Expand All @@ -36,6 +36,7 @@ console1=Console command - 1
console2=Console command - 2
how_to_use_gui=How to use GUI
troubleshoot=Troubleshooting
tips=Usage Tips

[gvv-mod-helpui]
diagnose=Diagnose
Expand Down Expand Up @@ -76,13 +77,13 @@ clear-report=Clear
6=__1__ : Access global [color=blue]LuaObject[/color] of Factorio.
7=__1__ : This tab.
8=You can find following entries in directory tree structures.
9= : A folder. Left click to open, right click to register at __1__.
10= : A variable key. Right click to register at __1__.
11= : A [color=blue]LuaObject[/color] object. Right click to register at __1__.
9= : A folder. Left click to open, right-click to register at __1__.
10= : A variable key. Right-click to register at __1__.
11= : A [color=blue]LuaObject[/color] object. Right-click to register at __1__.
12= : A not available(n/a) property in this [color=blue]LuaObject[/color].
13= : A method function in this [color=blue]LuaObject[/color]. [color=yellow]gvv[/color] does not support running methods from tree view.
14=But you can run methods via registering code directly by clicking empty space of __1__. If there is a return value of code, then it will be displayed. Be aware of that the execution result is applied.
15=Right clicking path of an entry in __1__ will display a window allowing you copy path or code.
15=Right-clicking path of an entry in __1__ will display a window allowing you copy path or code.
[gvv-mod-help-troubleshoot]
Expand All @@ -95,6 +96,26 @@ clear-report=Clear
7=Entries potentially problematic but not causing trouble now will not be removed by __1__. Only entries in [color=yellow]__2__[/color] are represented as deleted.
8=Clear [color=yellow]__1__[/color] :

[gvv-mod-help-tips]
1=Usage Tips
2=Using parts of [color=yellow]global[/color] table of map as space for memo
3=When running code using [font=default-bold]/c[/font] or [font=default-bold]/silent-command[/font], do you know whose [color=yellow]global[/color] is the [color=yellow]global[/color] you typing? That's the [color=yellow]global[/color] of the map("[color=yellow]level[/color]"). If [color=yellow]gvv[/color] can access [color=yellow]level[/color], you can write anything in it and track.
3-1=- Initialization code
3-2=- Example of memo - game.player.selected
3-3=- Example of memo - Written nothing yet
3-4=- To delete specific memo, after pasting, type number and press __1__.
3-5=Using [color=yellow]global[/color] table of [color=yellow]level[/color] in such way is a trick, and chat commands introduced above are not standard behavior of [color=yellow]gvv[/color] mod. I just introduced an another applicable way.
4=There are few more things can be right-clicked.
5=- Right-clicking __2__ or [font=var]return[/font] values in __1__ tab generates a window to allow copy contents.
5-word1=gray codes
6=- List entry at left side of __1__ tab can be removed by right-clicking.
7=- The all texts in a textfield for copying contents can be selected by right-clicking. You can copy them using __1__.
8=Monitoring arbitrary return value - 1
9=- Have you ever tried right-clicking on empty space under the __1__ tab? You can input any code have return value. But if working function is inside of the code, it may affect to game progress.
10=Monitoring arbitrary return value - 2
11=- You can find options at __1__, that allows to change default list of __2__ instead of examples.
[controls]
toggle-main-frame_gvv-mod=Open/close gvv window
Expand Down
21 changes: 21 additions & 0 deletions locale/ko/gvv.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ console1=콘솔 커맨드 - 1
console2=콘솔 커맨드 - 2
how_to_use_gui=GUI 사용 방법
troubleshoot=문제 해결
tips=사용 팁

[gvv-mod-helpui]
diagnose=진단
Expand Down Expand Up @@ -95,6 +96,26 @@ clear-report=지우기
7=지금 문제를 일으키진 않지만 잠재적으로 문제를 일으킬 수 있는 항목은 __1__에 의해서 삭제되지 않습니다. [color=yellow]__2__[/color] 항목만 삭제되는 것을 나타냅니다.
8=[color=yellow]__1__[/color] 지우기 :

[gvv-mod-help-tips]
1=사용 팁
2=지도의 [color=yellow]global[/color] 테이블 일부를 메모장처럼 사용하기
3=채팅 콘솔에 [font=default-bold]/c[/font] 또는 [font=default-bold]/silent-command[/font]를 사용해서 코드를 실행할 때, [color=yellow]global[/color]은 누구의 [color=yellow]global[/color]인지 아시나요? 그것은 지도("[color=yellow]level[/color]")의 [color=yellow]global[/color]입니다. [color=yellow]level[/color]에 [color=yellow]gvv[/color]가 액세스할 수 있다면 여기에 아무거나 적어넣고 추적할 수 있습니다.
3-1=- 초기화 코드
3-2=- 메모 예제 - game.player.selected
3-3=- 메모 예제 - 아직 아무것도 안적음
3-4=- 특정 메모만 지우려면, 붙여넣기 후, 숫자만 적고 __1__를 누름.
3-5=[color=yellow]level[/color]의 [color=yellow]global[/color] 테이블을 이런 식으로 사용하는건 트릭이며, 위에 소개한 채팅 커맨드들은 [color=yellow]gvv[/color] 모드의 표준 동작이 아닙니다. 다른 응용 방법을 하나 제시했을 뿐입니다.
4=우클릭이 가능한게 몇 가지 더 있습니다.
5=- __1__ 탭의 __2__ 또는 [font=var]return[/font] 값을 우클릭하면 내용을 복사할 수 있는 창이 생깁니다.
5-word1=회색 코드
6=- __1__ 탭의 왼쪽 리스트 항목을 우클릭해서 지울 수 있습니다.
7=- 내용을 복사할 수 있는 창의 내용은 우클릭하면 전체 선택할 수 있습니다. __1__를 사용해서 복사할 수 있습니다.
8=임의의 리턴 값을 모니터링하기 - 1
9=- __1__ 탭을 보고있을 때, 아래의 빈 공간에 우클릭을 해본적이 있나요? return값이 있는 어떤 코드든 넣을 수 있습니다. 다만 중간에 함수가 있으면 게임 진행에 영향을 줄 수 있습니다.
10=임의의 리턴 값을 모니터링하기 - 2
11=- __1__에서 지도를 처음부터 시작한 경우 __2__의 기본 목록으로 예제 대신에 다른것이 나오도록 할 수 있는 옵션을 찾을 수 있습니다.



[controls]
toggle-main-frame_gvv-mod=gvv 창 열기/닫기
Expand Down
5 changes: 4 additions & 1 deletion modules/gui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ Gui.open_main = function(player_index)
}
local tracking_panel = panel1.add{type = 'flow', name = '_gvv-mod_tracking_panel_', direction = 'vertical', style = 'vflow_gvv-mod'}
tracking_panel.style.vertical_spacing = 0
tracking_panel.style.horizontally_stretchable = true
tracking_panel.style.vertically_stretchable = true

tabpane.selected_tab_index = 1
Expand Down Expand Up @@ -281,7 +282,7 @@ Gui.open_main = function(player_index)
for k, v in pairs(g.data.tracking_list) do
pc, ret = pcall(function() Tracking.draw(panel, k, v) end)
if not pc then
player.print('[font=count-font]error caused when adding codes first time : '..k..'\n'..ret..'[/font]',{1,0.85,0.7,1})
player.print('[font=var-outline-gvv-mod]error caused when adding codes first time : '..k..'\n'..ret..'[/font]',{1,0.85,0.7,1})
end
end
else -- Example
Expand Down Expand Up @@ -405,6 +406,8 @@ Gui.copyable_tracking_code = function(player, str)
frame.destroy()
end

str = str:gsub('^“',''):gsub('”$','')

frame, closebtn, innerframe = Util.create_frame_w_closebtn(player, '_gvv-mod_copy_tracking_code_frame_', {"gvv-mod.copy-code"})
innerframe.add{type = 'textfield', name = '_gvv-mod_uneditable_text_',
text = str, clear_and_focus_on_right_click = true, tooltip = {"gvv-mod.right-to-select-all"},
Expand Down
4 changes: 4 additions & 0 deletions modules/gui_event.lua
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,10 @@ Gui_Event.on_gui_click = function(event)
elseif event.element.name == '_gvv-mod_tracking_path_str_' and event.button == defines.mouse_button_type.right then
Gui.copyable_tracking_code(player, event.element.caption)

--tracking_panel 의 결과값을 우클릭할 때
elseif event.element.name == '_gvv-mod_tracking_output_' and event.button == defines.mouse_button_type.right then
Gui.copyable_tracking_code(player, event.element.caption)

--tracking_panel 의 빈 공간을 우클릭할 때 (이 조건은 가능한한 뒤에)
elseif g.gui.tracking_panel and Util.find_parent_gui(event.element, g.gui.tracking_panel.parent) and event.button == defines.mouse_button_type.right then
Gui.put_anycode_in_tracking(g)
Expand Down
68 changes: 66 additions & 2 deletions modules/help_menu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ Help_Menu.page_list = {
name = 'troubleshoot',
caption = {"gvv-mod-help.troubleshoot"},
},
{
name = 'tips',
caption = {"gvv-mod-help.tips"},
},
}

Help_Menu.get_page = function(name)
Expand All @@ -38,12 +42,14 @@ local x
local p = {}
local this
local content_writer = {}
local looking_player_index

Help_Menu.draw_page = function(g, name)
local panel = g.gui.sub_helppanel
panel.clear()

p = {top = panel, pointer = panel}
looking_player_index = g.index
content_writer[name]()
end

Expand All @@ -56,10 +62,18 @@ local function text(locstr)
end

local function head(locstr)
local u = p.pointer.add{type = 'label', caption = locstr}
local u = p.pointer.add{type = 'label', caption = locstr, style = 'heading_1_label'}
u.style.horizontally_stretchable = true
u.style.single_line = false
this = u
return u
end

local function head2(locstr)
local u = p.pointer.add{type = 'label', caption = locstr, style = 'heading_2_label'}
u.style.horizontally_stretchable = true
u.style.single_line = false
u.style.font = 'heading-1'
u.style.left_padding = 7
this = u
return u
end
Expand Down Expand Up @@ -102,6 +116,13 @@ local function px()
return u
end

local function hr()
local u = p.pointer.add{type = 'line', direction = 'horizontal'}
u.style.horizontally_stretchable = true
this = u
return u
end

-------------------------------------
content_writer['control_lua'] = function()
x = 'gvv-mod-help-control_lua.'
Expand Down Expand Up @@ -261,4 +282,47 @@ px() end
end ---------------------------------


-------------------------------------
content_writer['tips'] = function()
x = 'gvv-mod-help-tips.'
-------------------------------------
head{x..'1'}
hr()
head2{x..'2'}
text{x..'3'}
text{x..'3-1'}
copyable('/c if not global._gvv then global._gvv={} end global._gvv["'..game.players[looking_player_index].name..'"]={}')
text{x..'3-2'}
local memo_prefix = '/silent-command local MEMO=global._gvv["'..game.players[looking_player_index].name..'"] game.player.print("MEMO#"..#MEMO+1) MEMO[#MEMO+1]= '
copyable(memo_prefix..'game.player.selected')
text{x..'3-3'}
copyable(memo_prefix)
text{x..'3-4', '[font=default-semibold][color=128, 206, 240]Enter[/color][/font]'}
copyable('/silent-command local t=setmetatable({},{__newindex=function(a,b,c) global._gvv["'..game.players[looking_player_index].name..'"][c]=nil game.player.print("MEMO#"..c.."=nil") end}) t[1]= ')
text{x..'3-5'}
text(' ')
hr()
head2{x..'4'}
text{x..'5',
{"",'[font=default-bold]',{"gvv-mod.tab-filtered-view"},'[/font]'},
{"",'[color=0.75,0.75,0.75,1]',{x..'5'..'-word1'},'[/color]'},
}
text{x..'6', {"",'[font=default-bold]','property','[/font]'}}
text{x..'7', '[font=default-semibold][color=128, 206, 240]Ctrl + C[/color][/font]'}
text(' ')
hr()
head2{x..'8'}
text{x..'9', {"",'[font=default-bold]',{"gvv-mod.tab-filtered-view"},'[/font]'}}
text(' ')
hr()
head2{x..'10'}
text{x..'11',
{"",'[font=default-bold]',{"gui-menu.game-menu"},' - ',{"gui-menu.settings"},' - ',{"gui-menu.mod-settings"},' - ',{"gui-mod-settings.map"},'[/font]'},
{"",'[font=default-bold]',{"gvv-mod.tab-filtered-view"},'[/font]'}
}
text(' ')

end ---------------------------------


return Help_Menu
2 changes: 1 addition & 1 deletion modules/register_event.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ local pcwrap = function(f)
local s, m = pcall(f,e)
if not s then
if e.player_index then
game.players[e.player_index].print('[font=count-font]'..m..'[/font]',{1,0.85,0.7,1})
game.players[e.player_index].print('[font=var-outline-gvv-mod]'..m..'[/font]',{1,0.85,0.7,1})
end
end
end
Expand Down
13 changes: 8 additions & 5 deletions modules/tracking.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ Tracking.draw = function(panel, path_str, full_path)
body.style.left_padding = 6
body.style.horizontal_spacing = 6
body.add{type = 'label', name = 'report', caption = ' = '}
body.add{type = 'label', name = 'out'}
body.out.style.font = 'default-bold'
body.add{type = 'label', name = '_gvv-mod_tracking_output_', tooltip = {"gvv-mod.right-to-copy-code"}}
body['_gvv-mod_tracking_output_'].style.font = 'default-bold'
local interline = container.add{type = 'line', direction = 'horizontal'}
end

Expand Down Expand Up @@ -63,9 +63,11 @@ end

Tracking.value_output = function(elem, full_path)
if type(full_path) == 'table' then
elem.body.out.caption = Table_to_str.value_to_str(Tree.get_tree_value(full_path))
elem.body['_gvv-mod_tracking_output_'].caption = Table_to_str.value_to_str(Tree.get_tree_value(full_path))
elem.body['_gvv-mod_tracking_output_'].style.font_color = {1,1,1}
elseif type(full_path) == 'string' then
elem.body.out.caption = Table_to_str.value_to_str(assert(loadstring('return '..full_path))())
elem.body['_gvv-mod_tracking_output_'].caption = Table_to_str.value_to_str(assert(loadstring('return '..full_path))())
elem.body['_gvv-mod_tracking_output_'].style.font_color = {1,1,1}
else
error('full_path is not table nor string')
end
Expand All @@ -78,7 +80,8 @@ Tracking.refresh_value = function(g)
for _, elem in pairs(panel.children) do
pc, ret = pcall(Tracking.value_output, elem, list[elem.name])
if not pc then
elem.body.out.caption = '[color=orange]'..ret..'[/color]'
elem.body['_gvv-mod_tracking_output_'].caption = ret
elem.body['_gvv-mod_tracking_output_'].style.font_color = { r = 1.000, g = 0.630, b = 0.259 }
end
end
end
Expand Down

0 comments on commit b6a4803

Please sign in to comment.