fix
This commit is contained in:
parent
8bfbb031a1
commit
856c1b8c48
79
.idea/workspace.xml
Normal file
79
.idea/workspace.xml
Normal file
@ -0,0 +1,79 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="AutoImportSettings">
|
||||
<option name="autoReloadType" value="ALL" />
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="f9d4c5b9-b129-4da9-ba9f-bbb71594fe20" name="Changes" comment="commit" />
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||
<option name="LAST_RESOLUTION" value="IGNORE" />
|
||||
</component>
|
||||
<component name="GOROOT" url="file:///usr/lib/go" />
|
||||
<component name="Git.Settings">
|
||||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||
</component>
|
||||
<component name="ProjectColorInfo"><![CDATA[{
|
||||
"associatedIndex": 3
|
||||
}]]></component>
|
||||
<component name="ProjectId" id="2XiP5d8wunfxWu8IyGgYD1Bv1kK" />
|
||||
<component name="ProjectLevelVcsManager">
|
||||
<ConfirmationsSetting value="2" id="Add" />
|
||||
</component>
|
||||
<component name="ProjectViewState">
|
||||
<option name="hideEmptyMiddlePackages" value="true" />
|
||||
<option name="showLibraryContents" value="true" />
|
||||
</component>
|
||||
<component name="PropertiesComponent"><![CDATA[{
|
||||
"keyToString": {
|
||||
"ASKED_ADD_EXTERNAL_FILES": "true",
|
||||
"ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true",
|
||||
"Go Build.go build asedraw.executor": "Run",
|
||||
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"RunOnceActivity.go.formatter.settings.were.checked": "true",
|
||||
"RunOnceActivity.go.migrated.go.modules.settings": "true",
|
||||
"RunOnceActivity.go.modules.automatic.dependencies.download": "true",
|
||||
"RunOnceActivity.go.modules.go.list.on.any.changes.was.set": "true",
|
||||
"SHARE_PROJECT_CONFIGURATION_FILES": "true",
|
||||
"git-widget-placeholder": "main",
|
||||
"go.import.settings.migrated": "true",
|
||||
"last_opened_file_path": "/home/bruno",
|
||||
"node.js.detected.package.eslint": "true",
|
||||
"node.js.selected.package.eslint": "(autodetect)",
|
||||
"nodejs_package_manager_path": "npm",
|
||||
"settings.editor.selected.configurable": "preferences.keymap"
|
||||
}
|
||||
}]]></component>
|
||||
<component name="RunManager">
|
||||
<configuration name="go build asedraw" type="GoApplicationRunConfiguration" factoryName="Go Application" nameIsGenerated="true">
|
||||
<module name="asedraw" />
|
||||
<working_directory value="$PROJECT_DIR$" />
|
||||
<kind value="PACKAGE" />
|
||||
<package value="asedraw" />
|
||||
<directory value="$PROJECT_DIR$" />
|
||||
<filePath value="$PROJECT_DIR$" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
</component>
|
||||
<component name="SharedIndexes">
|
||||
<attachedChunks>
|
||||
<set>
|
||||
<option value="bundled-gosdk-e6de5fef99a4-91e4cb603404-org.jetbrains.plugins.go.sharedIndexes.bundled-GO-233.11148" />
|
||||
</set>
|
||||
</attachedChunks>
|
||||
</component>
|
||||
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
|
||||
<component name="TypeScriptGeneratedFilesManager">
|
||||
<option name="version" value="3" />
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<option name="ADD_EXTERNAL_FILES_SILENTLY" value="true" />
|
||||
<MESSAGE value="commit" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="commit" />
|
||||
</component>
|
||||
<component name="VgoProject">
|
||||
<settings-migrated>true</settings-migrated>
|
||||
</component>
|
||||
</project>
|
@ -1 +0,0 @@
|
||||
/home/bruno/.config/aseprite/scripts/asedraw_client.lua
|
190
asedraw_client.lua
Normal file
190
asedraw_client.lua
Normal file
@ -0,0 +1,190 @@
|
||||
local dlg = Dialog()
|
||||
dlg:entry{ id="url", label="Server:", text="http://127.0.0.1:8797" }
|
||||
dlg:button{ id="yes", text="Connect" }
|
||||
dlg:button{ id="no", text="Cancel" }
|
||||
dlg:show()
|
||||
|
||||
local data = dlg.data
|
||||
|
||||
local connected = false
|
||||
|
||||
local images = {}
|
||||
|
||||
local function getimage(image)
|
||||
img = {}
|
||||
for x=0,image.width do
|
||||
tmp = {}
|
||||
for y=0,image.height do
|
||||
tmp[y] = image:getPixel(x, y)
|
||||
end
|
||||
img[x] = tmp
|
||||
end
|
||||
return img
|
||||
end
|
||||
|
||||
local function send(data)
|
||||
if connected then
|
||||
ws:sendText(json.encode(data))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local function handleMessage(mt, datain)
|
||||
if mt == WebSocketMessageType.OPEN then
|
||||
send({
|
||||
event = "connect",
|
||||
version = tostring(app.version),
|
||||
image = getimage(app.image)
|
||||
})
|
||||
connected = true
|
||||
|
||||
elseif mt == WebSocketMessageType.TEXT then
|
||||
local data = json.decode(datain)
|
||||
if data.event == "imagesetbytes" then
|
||||
app.image.bytes = data.image
|
||||
elseif data.event == "imagesetarray" then
|
||||
for x,column in ipairs(data.image) do
|
||||
for y,pixel in ipairs(column) do
|
||||
app.image:drawPixel(x, y, pixel)
|
||||
end
|
||||
end
|
||||
elseif data.event == "setpixel" then
|
||||
app.image:drawPixel(data.x, data.y, data.value)
|
||||
end
|
||||
|
||||
|
||||
elseif mt == WebSocketMessageType.CLOSE then
|
||||
connected = false
|
||||
ws:connect()
|
||||
end
|
||||
end
|
||||
|
||||
local function wsinit()
|
||||
ws = WebSocket{
|
||||
onreceive = handleMessage,
|
||||
url = data.url,
|
||||
deflate = true
|
||||
}
|
||||
end
|
||||
|
||||
app.events:on('sitechange',
|
||||
function()
|
||||
send({
|
||||
event = "sitechange"
|
||||
})
|
||||
end)
|
||||
|
||||
app.events:on('fgcolorchange',
|
||||
function()
|
||||
send({
|
||||
event = "fgcolorchange",
|
||||
color = app.fgColor.rgbaPixel
|
||||
})
|
||||
end)
|
||||
|
||||
app.events:on('bgcolorchange',
|
||||
function()
|
||||
send({
|
||||
event = "bgcolorchange",
|
||||
color = app.bgColor.rgbaPixel
|
||||
})
|
||||
end)
|
||||
|
||||
app.events:on('beforecommand',
|
||||
function(ev)
|
||||
send({
|
||||
event = "beforecommand",
|
||||
name = ev.name,
|
||||
params = ev.params
|
||||
})
|
||||
end)
|
||||
|
||||
app.events:on('aftercommand',
|
||||
function(ev)
|
||||
send({
|
||||
event = "aftercommand",
|
||||
name = ev.name,
|
||||
params = ev.params
|
||||
})
|
||||
end)
|
||||
|
||||
local function filenamechanged(ev)
|
||||
send({
|
||||
event = "filenamechange",
|
||||
filename = app.sprite.filename
|
||||
})
|
||||
end
|
||||
|
||||
local function spritechanged(ev)
|
||||
if images[app.image.id] == nil then
|
||||
images[app.image.id] = {
|
||||
version = app.image.version,
|
||||
bytes = app.image.bytes,
|
||||
data = getimage(app.image),
|
||||
width = app.image.width,
|
||||
height = app.image.height,
|
||||
colormode = app.image.colorMode,
|
||||
rowstride = app.image.rowStride
|
||||
}
|
||||
|
||||
elseif images[app.image.id].version ~= app.image.version then
|
||||
out["version"] = app.image.version
|
||||
images[app.image.id] = app.image.version
|
||||
|
||||
elseif images[app.image.id].bytes ~= app.image.bytes and images[app.image.id].width == app.image.width and images[app.image.id].height == app.image.height then
|
||||
local currentImage = getimage(app.image)
|
||||
local changes = {}
|
||||
for x,column in ipairs(currentImage.data) do
|
||||
for y,pixel in ipairs(column) do
|
||||
if images[app.image.id].data[x][y] ~= pixel then
|
||||
table.insert(changes, {
|
||||
x = x,
|
||||
y = y,
|
||||
value = pixel
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
send({
|
||||
event = "change",
|
||||
changes = changes,
|
||||
id = app.image.id
|
||||
})
|
||||
|
||||
elseif images[app.image.id].width ~= app.image.width or images[app.image.id].height ~= app.image.height then
|
||||
send({
|
||||
event = "sizechange",
|
||||
width = app.image.width,
|
||||
height = app.image.height,
|
||||
image = getimage(app.image),
|
||||
id = app.image.id
|
||||
})
|
||||
|
||||
elseif images[app.image.id].colorMode ~= app.image.colorMode then
|
||||
images[app.image.id].colorMode = app.image.colorMode
|
||||
send({
|
||||
event = "colormodechange",
|
||||
colormode = app.image.colorMode,
|
||||
id = app.image.id
|
||||
})
|
||||
|
||||
elseif images[app.image.id].rowStride ~= app.image.rowStride then
|
||||
images[app.image.id].rowStride = app.image.rowStride
|
||||
send({
|
||||
event = "rowstridechange",
|
||||
rowstride = app.image.rowStride,
|
||||
id = app.image.id
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local function registerspriteevents(sprite)
|
||||
sprite.events:on("filenamechange", filenamechanged)
|
||||
sprite.events:on("change", spritechanged)
|
||||
end
|
||||
|
||||
if data.yes then
|
||||
wsinit()
|
||||
ws:connect()
|
||||
end
|
Loading…
Reference in New Issue
Block a user