Skip to content

Commit

Permalink
Merge pull request #20 from veger/issue-3_surfaces
Browse files Browse the repository at this point in the history
Surface support
  • Loading branch information
veger authored Feb 8, 2021
2 parents d9e35e9 + 9033ffa commit d5f3dd7
Show file tree
Hide file tree
Showing 15 changed files with 373 additions and 52 deletions.
5 changes: 5 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
---------------------------------------------------------------------------------------------------
Version: 1.4.0

Features:
- Configurable surface for each camera (when multiple surfaces are available).
Hint: The 'Area Tracker' seems most suitable for small surfaces, as used in for example Factorissimo2.
- Configurable surface for each tracker (when multiple surfaces are available).
- Camera only uses trackers on same surface.
Minor Features:
- Add toggle/shortcut to pause all cameras.

Expand Down
5 changes: 5 additions & 0 deletions control.lua
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ script.on_event(defines.events.on_gui_checked_state_changed, TLBE.GUI.onStateCha
script.on_event(defines.events.on_runtime_mod_setting_changed, TLBE.Config.reload)
script.on_event(defines.events.on_player_created, on_player_created)
script.on_event(defines.events.on_player_joined_game, on_player_created)
script.on_event(defines.events.on_pre_surface_deleted, TLBE.GUI.onSurfaceChanged)
script.on_event(defines.events.on_surface_deleted, TLBE.GUI.onSurfacesUpdated)
script.on_event(defines.events.on_surface_created, TLBE.GUI.onSurfacesUpdated)
script.on_event(defines.events.on_surface_imported, TLBE.GUI.onSurfacesUpdated)
script.on_event(defines.events.on_surface_renamed, TLBE.GUI.onSurfaceChanged)
script.on_event(defines.events.on_built_entity, TLBE.Main.entity_built)
script.on_event(defines.events.on_rocket_launch_ordered, TLBE.Main.rocket_launch)
script.on_event(defines.events.on_rocket_launched, TLBE.Main.rocket_launched)
Expand Down
3 changes: 3 additions & 0 deletions locale/en/locale.cfg
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
camera-surface-deleted=Surface of camera '__1__' got deleted, camera will be disabled.
max-zoom=Max zoom reached, increase image size (or make base smaller)
migrated-camera=Migrated TLBE player settings to new camera settings.
migration-issue-framerate=Could not recover 'frame rate', please set manually as soon as possible. (only rocket tracker will not work as before)
Expand All @@ -23,6 +24,7 @@ label-name=Name:
label-position=Position:
label-resolution=Resolution:
label-size=Size:
label-surface=Surface:
label-smooth=Smooth camera movement
label-speedgain=Speed gain:
label-top-right=Top/Right:
Expand All @@ -49,6 +51,7 @@ tracker-enable=Enable/Disable tracker. (disabled trackers are skipped by the cam
tracker-area-map=Use map marker with name '__1__' to fill in this corner.
tracker-area-player=Use player coordinates to fill in this corner.
tracker-smooth=Enable/Disable smooth behavior of the camera when this tracker is active.
tracker-wrong-surface=Tracker is disabled because tracker surface differs from camera surface.

[controls]
tlbe-main-window-toggle=Open/Close camera settings
Expand Down
23 changes: 23 additions & 0 deletions migrations/tlbe.1.3.1.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
if global.playerSettings == nil then
goto SkipMigration
end

-- Set set camera and tracker surfaces to the default surface
for player_index, _ in pairs(game.players) do
local playerSettings = global.playerSettings[player_index]
if playerSettings == nil then
goto NextPlayer
end

for _, camera in pairs(playerSettings.cameras) do
camera.surfaceName = game.surfaces[1].name
end

for _, tracker in pairs(playerSettings.trackers) do
tracker.surfaceName = game.surfaces[1].name
end

::NextPlayer::
end

::SkipMigration::
11 changes: 11 additions & 0 deletions prototypes/styles.lua
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ default_gui["tlbe_fancy_list_box_image"] = {
stretch_image_to_widget_size = true
}

default_gui["tlbe_fancy_list_box_image_reduce_size"] = {
type = "image_style",
parent = "tlbe_fancy_list_box_image",
padding = 5,
}

default_gui["tlbe_fancy_list_box_button_hidden"] = {
type = "empty_widget_style",
width = 22,
Expand Down Expand Up @@ -281,6 +287,11 @@ default_gui["tlbe_config_textfield"] = {
width = 200
}

default_gui["tlbe_config_dropdown"] = {
type = "dropdown_style",
width = 200,
}

default_gui["tlbe_config_half_width_textfield"] = {
type = "textbox_style",
parent = "tlbe_config_textfield",
Expand Down
3 changes: 2 additions & 1 deletion scripts/camera.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ function Camera.newCamera(player, cameraList)
local camera = {
name = cameraName,
enabled = false,
surfaceName = game.surfaces[1].name,
entityInfo = false,
trackers = {},
centerPos = player.position,
Expand Down Expand Up @@ -115,7 +116,7 @@ function Camera.followTrackerSmooth(playerSettings, player, camera, tracker)

camera.zoom = minZoom
else
-- Max (min atually) zoom is not reached (anymore)
-- Max (min actually) zoom is not reached (anymore)
playerSettings.noticeMaxZoom = nil
end
end
Expand Down
Loading

0 comments on commit d5f3dd7

Please sign in to comment.