Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .luarc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://raw.githubusercontent.com/LuaLS/vscode-lua/master/setting/schema.json",
"workspace.ignoreDir": [
".vscode", ".github", "luals", "factorio"
".vscode", ".github", "luals", "factorio", "web"
],
"completion.requireSeparator": "/",
"runtime.pluginArgs": [
Expand Down
4 changes: 2 additions & 2 deletions exp_groups/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ export class ControllerPlugin extends BaseControllerPlugin {

async handleResolvedAssignmentSubscription(request: lib.SubscriptionRequest) {
// Check for any missing assignments to be computed on demand
const filters = Array.isArray(request.filters) ? request.filters : [request.filters!];
if (request.filters && filters.length) {
const filters = request.filters.toJSON();
if (filters.length) {
const missing = filters.filter(name => !this.resolvedAssignments.has(name));
if (missing.length) {
this.resolvedAssignments.setMany(await this.computeResolvedAssignments(missing));
Expand Down
8 changes: 4 additions & 4 deletions exp_groups/instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class InstancePlugin extends BaseInstancePlugin {
async onStart() {
// We use Date.now() because we need to manually initialise the groups on the lua side
await this.instance.sendTo("controller", new lib.SubscriptionRequest(
`exp_groups:${messages.GroupUpdatedEvent.name}`, true, Date.now()
`exp_groups:${messages.GroupUpdatedEvent.name}`, "subscribe", Date.now()
));
const groups = await this.instance.sendTo("controller", new messages.GroupListRequest())
await this.luaSendInitialGroups(groups);
Expand Down Expand Up @@ -118,13 +118,13 @@ export class InstancePlugin extends BaseInstancePlugin {

async subscribePlayerAssignment(playerName: string) {
await this.instance.sendTo("controller", new lib.SubscriptionRequest(
`exp_groups:${messages.ResolvedAssignmentUpdatedEvent.name}`, true, 0, playerName
`exp_groups:${messages.ResolvedAssignmentUpdatedEvent.name}`, "subscribe", 0, lib.SubscriptionFilters.fromShorthand(playerName)
));
}

async unsubscribePlayerAssignment(playerName: string) {
await this.instance.sendTo("controller", new lib.SubscriptionRequest(
`exp_groups:${messages.ResolvedAssignmentUpdatedEvent.name}`, false, 0, playerName
`exp_groups:${messages.ResolvedAssignmentUpdatedEvent.name}`, "unsubscribe", 0, lib.SubscriptionFilters.fromShorthand(playerName)
));
}

Expand Down Expand Up @@ -166,6 +166,6 @@ export class InstancePlugin extends BaseInstancePlugin {
}

async luaSend(receiver: string, json: any) {
await this.instance.sendRcon(`/c exp_groups.${receiver}(helpers.json_to_table[=[${JSON.stringify(json)}]=])`, true)
await this.instance.sendRcon(`/sc exp_groups.${receiver}(helpers.json_to_table[=[${JSON.stringify(json)}]=])`, true)
}
}
2 changes: 1 addition & 1 deletion exp_groups/web/components/GroupForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default function GroupForm({ open, setOpen }: {
const group = await control.send(new messages.GroupCreateRequest(
values.name, new messages.GroupPermissions(Boolean(values.isBlacklist), [])
));
navigate(`/exp_groups/${group.id}/view`);
navigate(`/permission_groups/${group.id}/view`);
setOpen(false);
}

Expand Down
6 changes: 3 additions & 3 deletions exp_groups/web/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ function ExpGroupsPage() {
}

export class WebPlugin extends BaseWebPlugin {
groups = new lib.EventSubscriber(messages.GroupUpdatedEvent, this.control);
assignments = new lib.EventSubscriber(messages.ManualAssignmentUpdatedEvent, this.control);
roleMappings = new lib.EventSubscriber(messages.RoleMappingUpdatedEvent, this.control);
groups = new lib.MapSubscriber(messages.GroupUpdatedEvent, this.control);
assignments = new lib.MapSubscriber(messages.ManualAssignmentUpdatedEvent, this.control);
roleMappings = new lib.MapSubscriber(messages.RoleMappingUpdatedEvent, this.control);

async init() {
this.pages = [
Expand Down
5 changes: 5 additions & 0 deletions exp_legacy/module/modules/data/quickbar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,14 @@ local ignored_items = {
--- Saves your quickbar preset to the script-output folder
Commands.new("save-quickbar", "Saves your Quickbar preset items to file")
:add_aliases{ "save-toolbar" }
:add_flags{ "disabled" }
:register(function(player)
local filters = {}

error("2.1 changes to get_quick_bar_slot beak compatibility with 2.0; waiting for upstream")
-- Upstream may add method to compat, or change inventory sync to have a quickbar only mode
for i = 1, 100 do
--[[
local slot = player.get_quick_bar_slot(i)
-- Need to filter out blueprint and blueprint books because the slot is a LuaItemPrototype and does not contain a way to export blueprint data
if slot ~= nil then
Expand All @@ -55,6 +59,7 @@ Commands.new("save-quickbar", "Saves your Quickbar preset items to file")
filters[i] = slot.name
end
end
]]
end

if next(filters) then
Expand Down
6 changes: 5 additions & 1 deletion exp_scenario/module/commands/home.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ commands.home = Commands.new("home", { "exp-commands_home.description-home" })

--- Teleports you to your previous location on the current surface
--- @class ExpCommand_Home.commands._return: ExpCommand
commands._return = Commands.new("return", { "exp-commands_home.description-return" })
commands.home_return = Commands.new("return", { "exp-commands_home.description-return" })
:add_flags{ "character_only" }
:register(function(player)
local surface = player.surface
Expand Down Expand Up @@ -120,3 +120,7 @@ commands.get_home = Commands.new("get-home", { "exp-commands_home.description-ge
local _, floor_position = align_to_grid(player_home[1])
return Commands.status.success{ "exp-commands_home.home-get", surface.localised_name, floor_position.x, floor_position.y }
end)

return {
commands = commands,
}
3 changes: 2 additions & 1 deletion exp_scenario/module/control.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ require("modules/exp_scenario/commands/_types")
--- Commands with events
add(require("modules/exp_scenario/commands/protected_entities"))
add(require("modules/exp_scenario/commands/protected_tags"))
add(require("modules/exp_scenario/commands/research"))

--- Commands
require("modules/exp_scenario/commands/admin_chat")
Expand Down Expand Up @@ -82,3 +81,5 @@ add(require("modules/exp_scenario/gui/rocket_info"))
add(require("modules/exp_scenario/gui/science_production"))
add(require("modules/exp_scenario/gui/surveillance"))
add(require("modules/exp_scenario/gui/task_list"))
add(require("modules/exp_scenario/gui/debug/shim"))
add(require("modules/exp_scenario/gui/debug/event_view"))
2 changes: 1 addition & 1 deletion exp_scenario/module/control/mine_depletion.lua
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ end
local max_mining_radius = 0
for _, proto in pairs(prototypes.get_entity_filtered{ { filter = "type", type = "mining-drill" } }) do
if proto.mining_drill_radius then
max_mining_radius = math.max(proto.get_mining_drill_radius(max_quality), max_mining_radius)
max_mining_radius = math.max(assert(proto.get_mining_drill_radius(max_quality)), max_mining_radius)
end
end

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local Gui = require("modules.exp_legacy.utils.gui") --- @dep utils.gui
local Model = require("modules.exp_legacy.modules.gui.debug.model") --- @dep modules.gui.debug.model
local Gui = require("modules/exp_scenario/gui/debug/shim")
local Model = require("modules/exp_scenario/gui/debug/model")
local Color = require("modules/exp_util/include/color")

local dump = Model.dump
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
local Event = require("modules/exp_legacy/utils/event")
local Storage = require("modules/exp_util/storage")
local Gui = require("modules.exp_legacy.utils.gui")
local Model = require("modules.exp_legacy.modules.gui.debug.model")
local Gui = require("modules/exp_scenario/gui/debug/shim")
local Model = require("modules/exp_scenario/gui/debug/model")

local format = string.format
local insert = table.insert
Expand All @@ -14,6 +13,7 @@ local events_to_keep = 10
-- Local vars
local Public = {
name = "Events",
events = {}
}
local name_lookup = {}

Expand Down Expand Up @@ -168,7 +168,7 @@ Gui.on_click(
-- Event registers (TODO: turn to removable hooks.. maybe)
for name, id in pairs(events) do
name_lookup[id] = name
Event.add(id, event_callback)
Public.events[id] = event_callback
end

return Public
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local Gui = require("modules.exp_legacy.utils.gui") --- @dep utils.gui
local Datastore = require("modules.exp_legacy.expcore.datastore") --- @dep expcore.datastore
local Gui = require("modules/exp_scenario/gui/debug/shim")
local Datastore = require("modules.exp_legacy.expcore.datastore")
local Color = require("modules/exp_util/include/color")
local Model = require("modules.exp_legacy.modules.gui.debug.model") --- @dep modules.gui.debug.model
local Model = require("modules/exp_scenario/gui/debug/model")

local dump = Model.dump
local concat = table.concat
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ local ExpData = require("modules/exp_gui/data")
local ExpIter = require("modules/exp_gui/iter")
local Color = require("modules/exp_util/include/color")

local Gui = require("modules.exp_legacy.utils.gui") --- @dep utils.gui
local Model = require("modules.exp_legacy.modules.gui.debug.model") --- @dep modules.gui.debug.model
local Gui = require("modules/exp_scenario/gui/debug/shim")
local Model = require("modules/exp_scenario/gui/debug/model")

local dump = Model.dump
local dump_text = Model.dump_text
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local Gui = require("modules.exp_legacy.utils.gui") --- @dep utils.gui
local Model = require("modules.exp_legacy.modules.gui.debug.model") --- @dep modules.gui.debug.model
local Gui = require("modules/exp_scenario/gui/debug/shim")
local Model = require("modules/exp_scenario/gui/debug/model")
local Color = require("modules/exp_util/include/color")

local dump = Model.dump
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
local Gui = require("modules.exp_legacy.utils.gui") --- @dep utils.gui
local Gui = require("modules/exp_scenario/gui/debug/shim")
local Color = require("modules/exp_util/include/color")

local Public = {}

local pages = {
require("modules.exp_legacy.modules.gui.debug.redmew_global_view"),
require("modules.exp_legacy.modules.gui.debug.expcore_datastore_view"),
require("modules.exp_legacy.modules.gui.debug.expcore_gui_view"),
require("modules.exp_legacy.modules.gui.debug.global_view"),
require("modules.exp_legacy.modules.gui.debug.package_view"),
require("modules.exp_legacy.modules.gui.debug._g_view"),
require("modules.exp_legacy.modules.gui.debug.event_view"),
require("modules/exp_scenario/gui/debug/redmew_global_view"),
require("modules/exp_scenario/gui/debug/expcore_datastore_view"),
require("modules/exp_scenario/gui/debug/expcore_gui_view"),
require("modules/exp_scenario/gui/debug/global_view"),
require("modules/exp_scenario/gui/debug/package_view"),
require("modules/exp_scenario/gui/debug/_g_view"),
require("modules/exp_scenario/gui/debug/event_view"),
}

local main_frame_name = Gui.uid_name()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
local Gui = require("modules.exp_legacy.utils.gui") --- @dep utils.gui
local Gui = require("modules/exp_scenario/gui/debug/shim") --- @dep utils.gui
local ExpUtil = require("modules/exp_util")

local concat = table.concat
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local Gui = require("modules.exp_legacy.utils.gui") --- @dep utils.gui
local Gui = require("modules/exp_scenario/gui/debug/shim") --- @dep utils.gui
local Color = require("modules/exp_util/include/color")
local Model = require("modules.exp_legacy.modules.gui.debug.model") --- @dep modules.gui.debug.model
local Model = require("modules/exp_scenario/gui/debug/model") --- @dep modules.gui.debug.model

local dump_function = Model.dump_function
local loaded = _G.package.loaded
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local Gui = require("modules.exp_legacy.utils.gui") --- @dep utils.gui
local Gui = require("modules/exp_scenario/gui/debug/shim") --- @dep utils.gui
local Storage = require("modules/exp_util/storage")
local Color = require("modules/exp_util/include/color")
local Model = require("modules.exp_legacy.modules.gui.debug.model") --- @dep modules.gui.debug.model
local Model = require("modules/exp_scenario/gui/debug/model") --- @dep modules.gui.debug.model

local dump = Model.dump
local dump_text = Model.dump_text
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
local Storage = require("modules/exp_util/storage")
local Event = require("modules/exp_legacy/utils/event")
local mod_gui = require "mod-gui"

local Gui = {}
Expand Down Expand Up @@ -70,14 +69,15 @@ function Gui.clear(element)
element.clear()
end

Gui.events = {}
local function handler_factory(event_name)
return function(element_name, handler)
Event.add(defines.events[event_name], function(event)
Gui.events[defines.events[event_name]] = function(event)
if event.element and event.element.valid and event.element.name == element_name then
event.player = game.players[event.player_index]
handler(event)
end
end)
end
end
end

Expand Down
4 changes: 2 additions & 2 deletions exp_scenario/module/gui/player_bonus.lua
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ Elements.bonus_slider = Gui.define("player_bonus/bonus_slider")
local player = Gui.get_player(parent)
local value = Elements.container.get_player_bonus(player, bonus_data.name)
if not value then
value = math.floor(bonus_data.initial_value / 2)
value = math.floor(bonus_data.max_value / 2)
elements.apply_button.enabled = true
end

Expand Down Expand Up @@ -289,7 +289,7 @@ function Elements.bonus_slider.reset_value(slider)
local player = Gui.get_player(slider)
local element_data = Elements.bonus_slider.data[slider]
local bonus_data = element_data.bonus_data
local value = Elements.container.get_player_bonus(player, bonus_data.name) or math.floor(bonus_data.initial_value / 2)
local value = Elements.container.get_player_bonus(player, bonus_data.name) or math.floor(bonus_data.max_value / 2)
slider.slider_value = value
element_data.label.caption = Elements.bonus_slider.calculate_slider_caption(bonus_data, value)
element_data.previous_value = value
Expand Down
2 changes: 1 addition & 1 deletion exp_scenario/module/gui/quick_actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ new_quick_action(addon_surface.commands.clear_ground_items)
new_quick_action(addon_surface.commands.clear_blueprints_surface)
new_quick_action(addon_surface.commands.clear_blueprints)
new_quick_action(addon_home.commands.home)
new_quick_action(addon_home.commands._return)
new_quick_action(addon_home.commands.home_return)
new_quick_action(addon_home.commands.set_home)
new_quick_action(addon_home.commands.get_home)
new_quick_action(addon_vlayer.commands.vlayer)
Expand Down
4 changes: 2 additions & 2 deletions exp_scenario/module/gui/readme.lua
Original file line number Diff line number Diff line change
Expand Up @@ -200,15 +200,15 @@ define_tab(
local container = parent.add{ type = "flow", direction = "vertical" }

local top_flow = container.add{ type = "flow" }
top_flow.add{ type = "sprite", sprite = "file/modules/exp_legacy/modules/gui/logo.png" }
top_flow.add{ type = "sprite", sprite = "file/modules/exp_scenario/gui/logo.png" }

local center_flow = top_flow.add{ type = "flow", direction = "vertical" }
center_flow.style.horizontal_align = "center"

Gui.elements.title_label(center_flow, 62, { "exp-gui_readme.welcome-title", server_details.name })
Gui.elements.centered_label(center_flow, 380, server_details.welcome)

top_flow.add{ type = "sprite", sprite = "file/modules/exp_legacy/modules/gui/logo.png" }
top_flow.add{ type = "sprite", sprite = "file/modules/exp_scenario/gui/logo.png" }

Gui.elements.bar(container)
container.add{ type = "flow" }.style.height = 4
Expand Down
Loading