Skip to content

Commit 37ca959

Browse files
committed
split wip
1 parent 43c6d2b commit 37ca959

File tree

200 files changed

+429
-263
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

200 files changed

+429
-263
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
RL2/res/music/
22
RL2/res/_musicsrc/
3+
RL2/client/res/music/

RL2/c1.cmd

-1
This file was deleted.
File renamed without changes.
File renamed without changes.

RL2/client/client/data/const.lua

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CLIENT_SAVE_DIR="client_save/"

RL2/client/editor_substate.lua RL2/client/client/editor_substate.lua

+22-7
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,14 @@ _.lastPlace.item=nil
99
local pageNumber=1
1010
-- pop on activate
1111
local maxPages=nil
12+
local isLoading=false
13+
local editorItems=nil
14+
1215

1316
local getCurrentItem=function()
1417
local registryPos = (C.editorCurrentRow-1)*C.editorCols+C.editorCurrentCol
1518
-- todo: read from server
16-
return Registry.editorItems[registryPos]
19+
return editorItems[registryPos]
1720
end
1821

1922

@@ -58,7 +61,7 @@ local moveFocus=function(dx,dy)
5861
end
5962

6063
local registryPos = (nextY-1)*C.editorCols+nextX
61-
local nextItem=Registry.editorItems[registryPos]
64+
local nextItem=editorItems[registryPos]
6265
if nextItem~=nil then
6366
C.editorCurrentCol=nextX
6467
C.editorCurrentRow=nextY
@@ -129,11 +132,20 @@ end
129132

130133

131134

135+
local onEditorItemsReceived=function(response)
136+
log("Editor items received")
137+
isLoading=false
138+
editorItems=response.editorItems
139+
end
140+
132141

133142
_.activate=function()
134143
--инпут идёт по цепочке стейтов, начиная с дочерних
135144
--table.insert(S.keyPressedListeners, onKeyPressed)
136145
_.parentstate.isDrawUi=false
146+
isLoading=true
147+
local command={cmd="editor_items_get"}
148+
Client.send(command, onEditorItemsReceived)
137149
end
138150

139151
_.deactivate=function()
@@ -172,21 +184,24 @@ _.startItemIndex=1
172184
_.draw=function()
173185
-- local line1="Editor coords:"..W.player.x..","..W.player.y
174186
-- LG.print(line1,Ui.rightbox.x+10,Ui.rightbox.y+5+100)
187+
188+
if isLoading or editorItems==nil then
189+
LG.print("Loading")
190+
return
191+
end
175192

176-
local itemsCount = #Registry.editorItems
177-
178-
if itemsCount==0 then return end
179193

180194
local itemIndex=_.startItemIndex
181-
local nextItem = Registry.editorItems[itemIndex]
195+
local nextItem = editorItems[itemIndex]
196+
if nextItem==nil then return end
182197

183198
for y=1,C.editorRows do
184199
for x=1,C.editorCols do
185200
if nextItem==nil then break end
186201
drawItem(nextItem,x,y)
187202

188203
itemIndex=itemIndex+1
189-
nextItem = Registry.editorItems[itemIndex]
204+
nextItem = editorItems[itemIndex]
190205
end
191206
if nextItem==nil then break end
192207
end
File renamed without changes.
File renamed without changes.

RL2/client/state_create_player.lua RL2/client/client/state_create_player.lua

+22-5
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,42 @@ local _={}
22

33
_.client=nil
44

5+
local isLoading=false
6+
local presets=nil
7+
58
local onPresetPicked=function()
69
_.client.switchToEnterNameState()
710
end
811

12+
local onPresetsReceived=function(response)
13+
log("presets received")
14+
isLoading=false
15+
presets=response.presets
16+
17+
end
18+
19+
920

1021
local onKeyPressed=function(key)
1122
local pick=tonumber(key)
1223
if pick==nil then return end
1324

1425
-- log("Key:"..key.." tonumber:"..pick)
1526

16-
local option=Registry.playerPresets[pick]
17-
if option==nil then return end
27+
if isLoading then return false end
28+
local option=presets[pick]
29+
if option==nil then return false end
1830

1931
-- log("Picked option:"..TSerial.pack(option))
2032

2133
_.client.send({cmd="preset_picked", pick=pick}, onPresetPicked)
22-
2334
end
2435

2536

2637
_.activate=function()
2738
subscribe(S.keyPressedListeners, onKeyPressed)
39+
_.client.send({cmd="players_presets_get"}, onPresetsReceived)
40+
isLoading=true
2841
end
2942

3043
_.deactivate=function()
@@ -40,11 +53,15 @@ end
4053
_.draw=function()
4154
LG.print("New player")
4255

56+
if isLoading then
57+
LG.print("loading..",0,20)
58+
return
59+
end
60+
4361
local y=40
4462
local yStep=40
4563
local x=10
46-
for k,preset in pairs(Registry.playerPresets) do
47-
64+
for k,preset in pairs(presets) do
4865
local sprite=Img[preset.spriteName]
4966

5067
LG.print(k,x,y)
File renamed without changes.

RL2/client/state_game.lua RL2/client/client/state_game.lua

+7-11
Original file line numberDiff line numberDiff line change
@@ -66,21 +66,17 @@ local dispatchCommand=function(command, isLocking, callback)
6666
end
6767
end
6868

69-
_.enterEditorMode=function()
70-
-- if S.isEditor then return end
71-
72-
S.isEditor=true
73-
74-
-- логичней это сделать в сабстейте редактора - на будущее
69+
local onEnteredEditorMode=function()
70+
unlock()
7571
local editorSubstate=require "client/editor_substate"
76-
77-
-- todo: после разрешения от сервера
7872
_.addSubstate(editorSubstate)
79-
80-
dispatchCommand({cmd="enter_editor_mode"}, true, unlock)
8173
end
8274

83-
--
75+
76+
_.enterEditorMode=function()
77+
S.isEditor=true
78+
dispatchCommand({cmd="enter_editor_mode"}, true, onEnteredEditorMode)
79+
end
8480

8581

8682
local commandMove=function(x,y)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

RL2/client/substate/state_inventory.lua RL2/client/client/substate/state_inventory.lua

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ end
7474
local addActionsForItem=function(item)
7575
if item.type=="seed" then
7676
addAction({name="Plant", code="plant"})
77+
else if item.type==""
7778
end
7879

7980
addAction({name="Drop", code="drop"})
File renamed without changes.

RL2/conf.lua RL2/client/conf.lua

File renamed without changes.

RL2/client/data/const.lua

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CLIENT_SAVE_DIR="client_save/"
File renamed without changes.

0 commit comments

Comments
 (0)