Skip to content

Commit

Permalink
Update code for v0.17
Browse files Browse the repository at this point in the history
* Update Readme screenshots
* Online Player List sprite change, and add spacing
* GUI visible changed to element instead of style (silo, GUI)
* Encapsulate file logic (spawn-marker, death-marker-simple)
* Tasks module icon/colors improvement
* Auto research  icon/colors improvement, and logic update
* game-info style naming changes
* Player Init RIP axes
  • Loading branch information
dddgamer committed Jun 24, 2019
1 parent 384770a commit 4c31fa8
Show file tree
Hide file tree
Showing 21 changed files with 175 additions and 89 deletions.
Binary file removed .screenshots/dddgamer-softmod_auto-research.jpg
Binary file not shown.
Binary file added .screenshots/dddgamer-softmod_auto-research.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed .screenshots/dddgamer-softmod_task-list.jpg
Binary file not shown.
Binary file added .screenshots/dddgamer-softmod_task-list.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Dev files will be removed from the release build, see the [github repository](ht

## Screenshots
![Game Start with softmod pack](.screenshots/dddgamer-softmod.jpg)
![Auto Research](.screenshots/dddgamer-softmod_auto-research.jpg)
![Task List](.screenshots/dddgamer-softmod_task-list.jpg)
![Auto Research](.screenshots/dddgamer-softmod_auto-research.png)
![Task List](.screenshots/dddgamer-softmod_task-list.png)
![Game Info](.screenshots/dddgamer-softmod_game-info.jpg)
![Player List](.screenshots/dddgamer-softmod_player-list.jpg)
4 changes: 2 additions & 2 deletions control.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ require('config')
-- ======================================================= --
-- require('modules/dev/for-testing')

-- Import Vanilla Modules if needed
-- == Import Vanilla Modules if needed == --
-- require('modules/vanilla/silo')
-- require('modules/vanilla/player-init')

-- Import Soft Mod Modules
-- == Import Soft Mod Modules == --
require('modules/common/spawn-marker')
require('modules/common/death-marker')
require('modules/common/autodeconstruct')
Expand Down
10 changes: 5 additions & 5 deletions modules/common/autodeconstruct.lua
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,9 @@ function autodeconstruct.check_drill(drill)
end

-- Handle cancelled deconstruction
function autodeconstruct.on_canceled_deconstruction(event)
function autodeconstruct.on_cancelled_deconstruction(event)
if event.player_index ~= nil or event.entity.type ~= 'mining-drill' then return end
if global.debug then msg_all({"autodeconstruct-debug", "on_canceled_deconstruction", util.positiontostr(event.entity.position) .. " deconstruction timed out, checking again"}) end
if global.debug then msg_all({"autodeconstruct-debug", "on_cancelled_deconstruction", util.positiontostr(event.entity.position) .. " deconstruction timed out, checking again"}) end
autodeconstruct.check_drill(event.entity)
end

Expand Down Expand Up @@ -283,9 +283,9 @@ Event.register(defines.events.on_player_created, function()
if err then msg_all({"autodeconstruct-err-generic", err}) end
end)

Event.register(defines.events.on_canceled_deconstruction, function(event)
local _, err = pcall(autodeconstruct.on_canceled_deconstruction, event)
if err then msg_all({"autodeconstruct-err-specific", "on_canceled_deconstruction", err}) end
Event.register(defines.events.on_cancelled_deconstruction, function(event)
local _, err = pcall(autodeconstruct.on_cancelled_deconstruction, event)
if err then msg_all({"autodeconstruct-err-specific", "on_cancelled_deconstruction", err}) end
end)

Event.register(defines.events.on_resource_depleted, function(event)
Expand Down
4 changes: 3 additions & 1 deletion modules/common/custom-tech.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ local DISABLED_RECIPE_LIST = {

-- Tech to begin researched with
local RESEARCH_TECH = {
'toolbelt'
'toolbelt',
'steel-axe',
'optics',
}

local PRINT_DISABLED_TECH = false
Expand Down
5 changes: 3 additions & 2 deletions modules/common/online-player-list.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
-- ======================================================= --
local mod_gui = require('mod-gui') -- From `Factorio\data\core\lualib`
local GUI = require('stdlib/GUI')
local Colors = require('util/Colors')
local Sprites = require('util/Sprites')
local Math = require('util/Math')
local Time = require('util/Time')

Expand All @@ -22,7 +22,7 @@ local Player_List = {
MASTER_FRAME_NAME = 'frame_playerlist',
CHECKBOX_OFFLINE_PLAYERS = 'chbx_playerlist_players',
SPRITE_NAMES = {
menu = 'entity/player',
menu = Sprites.character,
-- inventory = 'utility/grey_rail_signal_placement_indicator'
-- inventory = 'utility/item_editor_icon'
inventory = 'utility/slot_icon_armor'
Expand Down Expand Up @@ -137,6 +137,7 @@ function Player_List.draw_playerlist_frame()

-- Flow
local flow_header = master_frame.add({type = 'flow', direction = 'horizontal'})
flow_header.style.horizontal_spacing = 20

-- Draw checkbox
flow_header.add(
Expand Down
3 changes: 2 additions & 1 deletion modules/common/research-queue/Research_Queue_Styles.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ Research_Queue_Styles = {
bottom_padding = 0,
left_padding = 0,
horizontally_squashable = true,
vertically_squashable = true
vertically_squashable = true,
stretch_image_to_widget_size = true,
},
auto_research_sprite_button = {
width = 24,
Expand Down
90 changes: 69 additions & 21 deletions modules/common/research-queue/auto-research.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,21 @@ Auto_Research = {
MASTER_FRAME_LOCATION = GUI.MASTER_FRAME_LOCATIONS.left,
-- Check Factorio prototype definitions in \Factorio\data\core and \Factorio\data\base
SPRITE_NAMES = {
menu = 'item/lab',
up = 'utility/fluid_indication_arrow',
down = 'utility/hint_arrow_down',
blacklist = 'utility/clear',
remove = 'utility/set_bar_slot',
menu = Sprites.lab,
up = Sprites.hint_arrow_up,
down = Sprites.hint_arrow_down,
blacklist = Sprites.clear,
remove = Sprites.set_bar_slot,
tech_prefix = 'technology/',
item_prefix = 'item/',
},
-- Utf shapes https://www.w3schools.com/charsets/ref_utf_geometric.asp
-- Utf symbols https://www.w3schools.com/charsets/ref_utf_symbols.asp
TEXT_SYMBOLS = {
up = "",
down = ""
up = '',
down = '',
blacklist = '',
remove = '',
},
get_menu_button = function(player)
return GUI.menu_bar_el(player)[Auto_Research.MENU_BTN_NAME]
Expand All @@ -45,16 +49,15 @@ Auto_Research = {
end,
default_queued_techs = {
'automation',
'military-1',
'logistics',
'automation-2',
'turrets',
},
default_blacklisted_techs = {
'shotgun',
'shotgun-shell-damage-1',
'shotgun-shell-speed-1',
'combat-robotics',
},
default_allowed_research_ingredients = {
['science-pack-1'] = true
['automation-science-pack'] = true
}
}

Expand All @@ -66,6 +69,7 @@ Auto_Research = {
-- @param event on_player_joined_game
function Auto_Research.on_player_joined_game(event)
local player = game.players[event.player_index]
Auto_Research.disableDefaultGameQueue(player.force)
Auto_Research.setDefaultConfig(player.force)
Auto_Research.draw_menu_btn(player)
-- Auto_Research.draw_master_frame(player) -- Will appear on load, cooment out to load later on button click
Expand Down Expand Up @@ -137,7 +141,6 @@ function Auto_Research.GUI_onClick(event)
local config = Auto_Research.getConfig(force)
local name = event.element.name
if name == "auto_research_enabled" then
game.print(serpent.block(event.element.state))
Auto_Research.setAutoResearch(force, event.element.state)
elseif name == "auto_research_queued_only" then
Auto_Research.setQueuedOnly(force, event.element.state)
Expand Down Expand Up @@ -592,31 +595,46 @@ function Auto_Research.GUI_updateTechnologyList(scrollpane, technologies, player
entryflow.add {
type = "sprite-button",
name = "auto_research_queue_top-" .. techname,
sprite = GUI.get_safe_sprite_name(player, Auto_Research.SPRITE_NAMES.up),
caption = Auto_Research.TEXT_SYMBOLS.up,
-- sprite = GUI.get_safe_sprite_name(player, Auto_Research.SPRITE_NAMES.up),
tooltip = 'Move to beginning of Queue'
}
GUI.element_apply_style(temp_var_for_el_style, Research_Queue_Styles.auto_research_sprite_button)
GUI.element_apply_style(temp_var_for_el_style, Styles.txt_clr_blue)
temp_var_for_el_style =
entryflow.add {
type = "sprite-button",
name = "auto_research_queue_bottom-" .. techname,
sprite = GUI.get_safe_sprite_name(player, Auto_Research.SPRITE_NAMES.down),
caption = Auto_Research.TEXT_SYMBOLS.down,
-- sprite = GUI.get_safe_sprite_name(player, Auto_Research.SPRITE_NAMES.down),
tooltip = 'Move to end of Queue'
}
GUI.element_apply_style(temp_var_for_el_style, Research_Queue_Styles.auto_research_sprite_button)
GUI.element_apply_style(temp_var_for_el_style, Styles.txt_clr_blue)
end
temp_var_for_el_style =
entryflow.add {
type = "sprite-button",
name = "auto_research_delete-" .. techname,
sprite = GUI.get_safe_sprite_name(player, Auto_Research.SPRITE_NAMES.remove),
caption = Auto_Research.TEXT_SYMBOLS.remove,
-- sprite = GUI.get_safe_sprite_name(player, Auto_Research.SPRITE_NAMES.remove),
tooltip = 'Remove'
}
GUI.element_apply_style(temp_var_for_el_style, Research_Queue_Styles.auto_research_sprite_button)
GUI.element_apply_style(temp_var_for_el_style, Styles.txt_clr_red)

-- Tech icon
local sprite = GUI.get_safe_sprite_name(player, Auto_Research.SPRITE_NAMES.tech_prefix .. techname)
temp_var_for_el_style = entryflow.add {type = "sprite", sprite = sprite}
GUI.element_apply_style(temp_var_for_el_style, Research_Queue_Styles.auto_research_sprite)

-- Research text name
temp_var_for_el_style = entryflow.add {type = "label", caption = tech.localised_name}
GUI.element_apply_style(temp_var_for_el_style, Research_Queue_Styles.auto_research_tech_label)

-- Research science req (pots)
for _, ingredient in pairs(tech.research_unit_ingredients) do
local sprite = GUI.get_safe_sprite_name(player, "item/" .. ingredient.name)
local sprite = GUI.get_safe_sprite_name(player, Auto_Research.SPRITE_NAMES.item_prefix .. ingredient.name)
temp_var_for_el_style = entryflow.add {type = "sprite", sprite = sprite}
GUI.element_apply_style(temp_var_for_el_style, Research_Queue_Styles.auto_research_sprite)
end
Expand Down Expand Up @@ -748,28 +766,43 @@ function Auto_Research.GUI_updateSearchResult(player, text)
entryflow.add {
type = "sprite-button",
name = "auto_research_queue_top-" .. name,
sprite = GUI.get_safe_sprite_name(player, Auto_Research.SPRITE_NAMES.up),
caption = Auto_Research.TEXT_SYMBOLS.up,
-- sprite = GUI.get_safe_sprite_name(player, Auto_Research.SPRITE_NAMES.up),
tooltip = 'Move to beginning of Queue'
}
GUI.element_apply_style(temp_var_for_el_style, Research_Queue_Styles.auto_research_sprite_button)
GUI.element_apply_style(temp_var_for_el_style, Styles.txt_clr_blue)
temp_var_for_el_style =
entryflow.add {
type = "sprite-button",
name = "auto_research_queue_bottom-" .. name,
sprite = GUI.get_safe_sprite_name(player, Auto_Research.SPRITE_NAMES.down),
caption = Auto_Research.TEXT_SYMBOLS.down,
-- sprite = GUI.get_safe_sprite_name(player, Auto_Research.SPRITE_NAMES.down),
tooltip = 'Move to end of Queue'
}
GUI.element_apply_style(temp_var_for_el_style, Research_Queue_Styles.auto_research_sprite_button)
GUI.element_apply_style(temp_var_for_el_style, Styles.txt_clr_blue)
temp_var_for_el_style =
entryflow.add {
type = "sprite-button",
name = "auto_research_blacklist-" .. name,
sprite = GUI.get_safe_sprite_name(player, Auto_Research.SPRITE_NAMES.blacklist),
caption = Auto_Research.TEXT_SYMBOLS.blacklist,
-- sprite = GUI.get_safe_sprite_name(player, Auto_Research.SPRITE_NAMES.blacklist),
tooltip = 'Blacklist'
}
GUI.element_apply_style(temp_var_for_el_style, Research_Queue_Styles.auto_research_sprite_button)
GUI.element_apply_style(temp_var_for_el_style, Styles.txt_clr_red)

-- Tech icon
local sprite = GUI.get_safe_sprite_name(player, Auto_Research.SPRITE_NAMES.tech_prefix .. name)
temp_var_for_el_style = entryflow.add {type = "sprite", sprite = sprite}
GUI.element_apply_style(temp_var_for_el_style, Research_Queue_Styles.auto_research_sprite)

-- Research text name
temp_var_for_el_style = entryflow.add {type = "label", name = name, caption = tech.localised_name}
GUI.element_apply_style(temp_var_for_el_style, Research_Queue_Styles.auto_research_tech_label)

-- Research science req (pots)
for _, ingredient in pairs(tech.research_unit_ingredients) do
local sprite = GUI.get_safe_sprite_name(player, "item/" .. ingredient.name)
temp_var_for_el_style = entryflow.add({type = "sprite", sprite = sprite})
Expand Down Expand Up @@ -1042,5 +1075,20 @@ function Auto_Research.startNextResearch(force, override_spam_detection)
end
end

force.current_research = next_research
-- v0.16 Intention
-- force.current_research = next_research

-- v0.17 Adaptation of the above
-- We overwrite what ever the game has in the queue with the next tech from this custom queue
if(next_research) then
force.research_queue = nil;
-- force.cancel_current_research();
force.add_research(next_research);
end
end


-- Disable the default recearch qeue that ships with the game and use ours instead
function Auto_Research.disableDefaultGameQueue(force)
force.research_queue_enabled = false;
end
4 changes: 2 additions & 2 deletions modules/common/silo.lua
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ function draw_rocket_score_frame(player)

-- Hide if no rockets launched yet
if (player.force.rockets_launched <= 0) then
frame.style.visible = false
frame.visible = false
end
end

Expand All @@ -121,5 +121,5 @@ function update_score(player)
label.caption = {'silo.rocket_score', rocket_score}

-- Show the score on first rocket launch
if(rocket_score == 1) then frame.style.visible = true end
if(rocket_score == 1) then frame.visible = true end
end
13 changes: 8 additions & 5 deletions modules/common/spawn-marker.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,36 +9,39 @@
-- Constants --
-- ======================================================= --

local SpawnMarker = {}

-- Event Functions --
-- ======================================================= --

-- Various action when new player joins in game
-- @param event on_player_created event
function on_player_created(event)
function SpawnMarker.on_player_created(event)
local player = game.players[event.player_index]
if (not global.spawn_marked_on_map) then
set_map_spawn_marker(player)
SpawnMarker.set_map_spawn_marker(player)
global.spawn_marked_on_map = true
end
end

-- Event Registration --
-- ======================================================= --
Event.register(defines.events.on_player_created, on_player_created)
Event.register(defines.events.on_player_created, SpawnMarker.on_player_created)

-- Helper Functions --
-- ======================================================= --

-- Set spawn mark on map
-- @param player LuaPlayer
function set_map_spawn_marker(player)
function SpawnMarker.set_map_spawn_marker(player)
local spawn_position = player.force.get_spawn_position(player.surface)
local map_tag = {
position = spawn_position,
text = 'Spawn',
icon = {type = 'item', name = 'heavy-armor'}
}

-- FIXME: This doesnt work for some reason while the one on death does.
-- FIXME: This doesnt work b/c area is not yet charted
-- Adding a chart call before this doesnt fix the problem as it seems to be async.
player.force.add_chart_tag(player.surface, map_tag)
end
Loading

0 comments on commit 4c31fa8

Please sign in to comment.