Skip to content

Commit

Permalink
Used new functions to restrict text fields to numbers only
Browse files Browse the repository at this point in the history
  • Loading branch information
Bilka2 committed Jul 16, 2019
1 parent 70fcbb5 commit a1e7e01
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 9 deletions.
5 changes: 5 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
---------------------------------------------------------------------------------------------------
Version: 3.1.4
Date: 16. 07. 2018
Minor Features:
- Used new functions to restrict text fields to numbers only.
---------------------------------------------------------------------------------------------------
Version: 3.1.3
Date: 31. 05. 2018
Bugfixes:
Expand Down
5 changes: 4 additions & 1 deletion gui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,10 @@ gui.regen = function(player)
map_gen_flow1.add{
type = "textfield",
name = "change-map-settings-seed-textfield",
text = "0"
text = "0",
numeric = true,
allow_decimal = false,
allow_negative = false
}

-- rest of map gen settings
Expand Down
4 changes: 2 additions & 2 deletions info.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "ChangeMapSettings",
"version": "3.1.3",
"version": "3.1.4",
"factorio_version" : "0.17",
"title": "Change Map Settings",
"author": "Bilka",
"homepage": "",
"description": "Allows you to change your map and map generation settings at any time you want.",
"dependencies": [ "base >= 0.17.43" ]
"dependencies": [ "base >= 0.17.58" ]
}
23 changes: 18 additions & 5 deletions map_gen_settings_gui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,10 @@ map_gen_gui.create_enemies_table = function(parent)
table.add{
type = "textfield",
name = ENTIRE_PREFIX .. "starting-area-size",
style = "short_number_textfield"
style = "short_number_textfield",
numeric = true,
allow_decimal = true,
allow_negative = true
}
end

Expand All @@ -304,18 +307,27 @@ map_gen_gui.make_autoplace_options = function(name, parent, has_richness)
parent.add{
type = "textfield",
name = ENTIRE_PREFIX .. name .. "-freq",
style = "short_number_textfield"
style = "short_number_textfield",
numeric = true,
allow_decimal = true,
allow_negative = true
}
parent.add{
type = "textfield",
name = ENTIRE_PREFIX .. name .. "-size",
style = "short_number_textfield"
style = "short_number_textfield",
numeric = true,
allow_decimal = true,
allow_negative = true
}
if has_richness then
parent.add{
type = "textfield",
name = ENTIRE_PREFIX .. name .. "-richn",
style = "short_number_textfield"
style = "short_number_textfield",
numeric = true,
allow_decimal = true,
allow_negative = true
}
end
end
Expand Down Expand Up @@ -381,11 +393,12 @@ map_gen_gui.set_to_current = function(parent, map_gen_settings)
-- expression selectors
local possible_properties = util.get_possible_noise_expression_properties()
local relevant_noise_expressions = util.get_relevant_noise_expressions()
local valid_named_noise_expressions = game.named_noise_expressions
for _, property in pairs(possible_properties) do
local selected_expression = property_expression_names[property]
if selected_expression then
local noise_expressions_list_item
if game.named_noise_expressions[selected_expression] then -- proper noise expression, not just some number
if valid_named_noise_expressions[selected_expression] then -- proper noise expression, not just some number
noise_expressions_list_item = {"noise-expression." .. selected_expression}
else
noise_expressions_list_item = selected_expression -- number that is really a string. we just use it directly
Expand Down
5 changes: 4 additions & 1 deletion map_settings_gui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,10 @@ map_settings_gui.make_config_option = function(parent, name, caption, tooltip, d
local child = parent.add{
type = "textfield",
name = ENTIRE_PREFIX .. name .. "-textfield",
text = default
text = default,
numeric = true,
allow_decimal = true,
allow_negative = false
}
if max_width then child.style.maximal_width = max_width end
return child
Expand Down

0 comments on commit a1e7e01

Please sign in to comment.