Skip to content

Commit

Permalink
#67 Added input text from evasia
Browse files Browse the repository at this point in the history
  • Loading branch information
Ismoh committed May 20, 2023
1 parent 77acced commit 98a6dae
Show file tree
Hide file tree
Showing 12 changed files with 3,823 additions and 21 deletions.
8 changes: 8 additions & 0 deletions mods/noita-mp/files/data/entities/input_manager.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Entity name="input_manager" tags="input_manager">
<ControlsComponent
_enabled="1"
enabled="1"
></ControlsComponent>

<StreamingKeepAliveComponent/>
</Entity>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions mods/noita-mp/files/scripts/Ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Ui = {}
-- 'Imports'
local renderEzgui = dofile_once("mods/noita-mp/lua_modules/share/lua/5.1/ezgui/EZGUI.lua").init(
"mods/noita-mp/lua_modules/share/lua/5.1/ezgui")
local textInput = require("input-manager.text_input")


--- Global private variables:
Expand Down Expand Up @@ -130,6 +131,9 @@ function Ui.new()
}
}

gui = gui or GuiCreate()
self.nameTextInput = textInput.create(gui, 25, height - 25, 200, "Type in your name!", 20, nil, nil, 100)



-- Private methods:
Expand Down Expand Up @@ -357,6 +361,8 @@ function Ui.new()
GuiColorSetForNextWidget(gui, 1, 0, 0, 1)
GuiText(gui, 100, 100, "Memory is about to overflow. Please save and quit the game.")
end
self.nameTextInput:draw()
self.nameTextInput:update()
end

-- Apply some private methods
Expand Down
16 changes: 8 additions & 8 deletions mods/noita-mp/files/scripts/net/Server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -971,14 +971,14 @@ function ServerInit.new(sockServer)
return sent
end

--function self.sendNewNuid(owner, localEntityId, newNuid, x, y, rotation, velocity, filename, health, isPolymorphed)
-- local cpc017 = CustomProfiler.start("Server.sendNewNuid")
-- local event = NetworkUtils.events.newNuid.name
-- local data = { NetworkUtils.getNextNetworkMessageId(), owner, localEntityId, newNuid, x, y, rotation, velocity, filename, health, isPolymorphed }
-- local sent = self:sendToAll(event, data)
-- CustomProfiler.stop("Server.sendNewNuid", cpc017)
-- return sent
--end
function self.sendNewNuid(owner, localEntityId, newNuid, x, y, rotation, velocity, filename, health, isPolymorphed)
local cpc017 = CustomProfiler.start("Server.sendNewNuid")
local event = NetworkUtils.events.newNuid.name
local data = { NetworkUtils.getNextNetworkMessageId(), owner, localEntityId, newNuid, x, y, rotation, velocity, filename, health, isPolymorphed }
local sent = self:sendToAll(event, data)
CustomProfiler.stop("Server.sendNewNuid", cpc017)
return sent
end

function self.sendNewNuidSerialized(ownerName, ownerGuid, entityId, serializedEntity, nuid)
local cpc026 = CustomProfiler.start("Server.sendNewNuidSerialized")
Expand Down
14 changes: 9 additions & 5 deletions mods/noita-mp/files/scripts/util/EntitySerialisationUtils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -526,12 +526,13 @@ EntitySerialisationUtils.serializeEntityComponents = function(entityId, startF
local componentIds = EntityGetAllComponents(entityId)

local _i = 1
local cachedEntity = nil
if EntityCache.contains(entityId) then
local cachedEntity = EntityCache.get(entityId)
cachedEntity = EntityCache.get(entityId)
_i = #cachedEntity.serialisedRootEntity.components or 1
for i = 1, #cachedEntity.serialisedRootEntity.components do
_i = i
end
--for i = 1, #cachedEntity.serialisedRootEntity.components do
-- _i = i
--end
end

for i = _i, #componentIds do
Expand Down Expand Up @@ -591,10 +592,13 @@ EntitySerialisationUtils.serializeEntityComponents = function(entityId, startF
end
end
end
else
-- we need to store ignored components for stupid lua table size/count
components[i] = {}
end

local now = GameGetRealWorldTimeSinceStarted()
if startFrameTime - now >= EntityUtils.maxExecutionTime then
if now - startFrameTime >= EntityUtils.maxExecutionTime then
-- stop execution, when we are running out of time
return false, components
end
Expand Down
17 changes: 11 additions & 6 deletions mods/noita-mp/files/scripts/util/EntityUtils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,14 @@ end
OnEntityRemoved = function(entityId, nuid)
local cpc = CustomProfiler.start("OnEntityRemoved")
local _nuid, _entityId = GlobalsUtils.getNuidEntityPair(nuid)
if entityId ~= _entityId then

-- _entityId can be nil if the entity was removed before it was fully loaded
if not Utils.IsEmpty(_entityId) and entityId ~= _entityId then
error(("EntityUtils.OnEntityRemoved: entityId %s ~= _entityId %s"):format(entityId, _entityId), 2)
end
if nuid ~= _nuid then

-- _nuid can be nil if the entity was removed before it was fully loaded
if not Utils.IsEmpty(_nuid) and nuid ~= _nuid then
error(("EntityUtils.OnEntityRemoved: nuid %s ~= _nuid %s"):format(nuid, _nuid), 2)
end
EntityCache.delete(entityId)
Expand Down Expand Up @@ -493,7 +497,8 @@ function EntityUtils.processAndSyncEntityNetworking(startFrameTime)
elseif who == Client.iAm and not hasNuid then
Client.sendNeedNuid(ownerName, ownerGuid, entityId)
else
error("Unable to get whoAmI()!", 2)
--error("Unable to get whoAmI()!", 2)
return
end

NetworkVscUtils.addOrUpdateAllVscs(entityId, ownerName, ownerGuid, nuid)
Expand All @@ -512,8 +517,8 @@ function EntityUtils.processAndSyncEntityNetworking(startFrameTime)
NetworkVscUtils.addOrUpdateAllVscs(entityId, compOwnerName, compOwnerGuid, nuid)
end
end
--Server.sendNewNuid({ compOwnerName, compOwnerGuid }, entityId, nuid, x, y, rotation, velocity,
-- filename, health, EntityUtils.isEntityPolymorphed(entityId))
Server.sendNewNuid({ compOwnerName, compOwnerGuid }, entityId, nuid, x, y, rotation, velocity,
filename, health, EntityUtils.isEntityPolymorphed(entityId))
local finished, serializedEntity = EntitySerialisationUtils.serializeEntireRootEntity(entityId, nuid, startFrameTime)
--local ONLYFORTESTING = EntitySerialisationUtils.deserializeEntireRootEntity(serializedEntity)
if finished == true then
Expand All @@ -524,7 +529,7 @@ function EntityUtils.processAndSyncEntityNetworking(startFrameTime)
-- when executionTime is too long, return the next entityCacheIndex to continue with it
--prevEntityIndex = entityIndex + 1
EntityCacheUtils.set(entityId, nuid, compOwnerGuid, compOwnerName, filename, x, y, rotation,
velocity.x, velocity.y, health.current, health.max, finished, serializedEntity)
velocity.x, velocity.y, health.current, health.max, finished, serializedEntity)
CustomProfiler.stop("EntityUtils.processAndSyncEntityNetworking", cpc)
return -- completely end function, because it took too long
end
Expand Down
5 changes: 3 additions & 2 deletions mods/noita-mp/files/scripts/util/NoitaComponentUtils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,12 @@ function NoitaComponentUtils.addOrGetNetworkSpriteStatusIndicator(entityId)
else
compId = EntityAddComponent2(entityId, "SpriteComponent", {
image_file = "mods/noita-mp/files/data/debug/network_indicator_off.png",
ui_is_parent = false,
offset_x = 0,
offset_y = 0,
offset_y = -3,
alpha = 1,
visible = true,
z_index = 0.6,
z_index = 255,
update_transform = true,
special_scale_x = 1,
special_scale_y = 1
Expand Down
Binary file not shown.
Loading

0 comments on commit 98a6dae

Please sign in to comment.