-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- UI page for settings - show farmland owner on menu map page - show # of jobs under NPC farmer image - repackage source files
- Loading branch information
Showing
23 changed files
with
1,884 additions
and
545 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
--======================================================================================================= | ||
-- BetterContracts SCRIPT | ||
-- | ||
-- Purpose: Enhance ingame contracts menu. | ||
-- Author: Mmtrx | ||
-- Changelog: | ||
-- v1.2.6.0 30.11.2022 UI for all settings | ||
--======================================================================================================= | ||
|
||
BCSettingsPage = { | ||
CONTROLS = { | ||
"header", | ||
"subTitlePrefab", | ||
"multiTextOptionPrefab", | ||
"settingsContainer", | ||
"boxLayout" | ||
}, | ||
} | ||
local BCSettingsPage_mt = Class(BCSettingsPage, TabbedMenuFrameElement) | ||
|
||
function BCSettingsPage.new(target, custom_mt) | ||
local self = TabbedMenuFrameElement.new(target, custom_mt or BCSettingsPage_mt) | ||
self:registerControls(BCSettingsPage.CONTROLS) | ||
self.settings = BetterContracts.settings | ||
self.settingsBySubtitle = BCSettingsBySubtitle | ||
return self | ||
end | ||
function generateGuiElements(settingsBySubTitle, parentGuiElement, genericSettingElement, genericSubTitleElement) | ||
for _, data in ipairs(settingsBySubTitle) do | ||
local clonedSubTitleElement = genericSubTitleElement:clone(parentGuiElement) | ||
clonedSubTitleElement:setText(g_i18n:getText(data.title)) | ||
FocusManager:loadElementFromCustomValues(clonedSubTitleElement) | ||
for _, setting in ipairs(data.elements) do | ||
local cloned = genericSettingElement:clone(parentGuiElement) | ||
if cloned.labelElement and cloned.labelElement.setText then | ||
cloned:setLabel(g_i18n:getText(setting.title)) | ||
end | ||
local toolTipElement = cloned.elements[6] | ||
if toolTipElement then | ||
toolTipElement:setText(g_i18n:getText(setting.tooltip)) | ||
end | ||
FocusManager:loadElementFromCustomValues(cloned) | ||
end | ||
end | ||
parentGuiElement:invalidateLayout() | ||
end | ||
function linkGuiElementsAndSettings(settings, layout) | ||
local i = 1 -- index for settings | ||
for ix, element in ipairs(layout.elements) do | ||
if element:isa(MultiTextOptionElement) then | ||
settings[i]:setGuiElement(element) | ||
i = i + 1 | ||
end | ||
end | ||
end | ||
function BCSettingsPage:onGuiSetupFinished() | ||
BCSettingsPage:superClass().onGuiSetupFinished(self) | ||
|
||
self.subTitlePrefab:unlinkElement() | ||
FocusManager:removeElement(self.subTitlePrefab) | ||
self.multiTextOptionPrefab:unlinkElement() | ||
FocusManager:removeElement(self.multiTextOptionPrefab) | ||
|
||
self.header:setText(g_i18n:getText("bc_settingsPage_title")) | ||
generateGuiElements(self.settingsBySubtitle, | ||
self.boxLayout,self.multiTextOptionPrefab, self.subTitlePrefab) | ||
self.boxLayout:invalidateLayout() | ||
end | ||
function BCSettingsPage:onFrameOpen() | ||
BCSettingsPage:superClass().onFrameOpen(self) | ||
|
||
linkGuiElementsAndSettings(self.settings, self.boxLayout) | ||
|
||
FocusManager:loadElementFromCustomValues(self.boxLayout) | ||
self.boxLayout:invalidateLayout() | ||
self:setSoundSuppressed(true) | ||
FocusManager:setFocus(self.boxLayout) | ||
self:setSoundSuppressed(false) | ||
end | ||
function BCSettingsPage:onFrameClose() | ||
BCSettingsPage:superClass().onFrameClose(self) | ||
--unlinkGuiElementsAndSettings(self.settings,self.boxLayout) | ||
self.boxLayout:invalidateLayout() | ||
end | ||
function BCSettingsPage:updateDisabled(layout) | ||
if g_gui:getIsGuiVisible() and g_currentMission.inGameMenu.currentPage == self then | ||
for _, element in ipairs(layout.elements) do | ||
if element:isa(MultiTextOptionElement) then | ||
local isDisabledFunc = element.bc_setting.isDisabledFunc | ||
if isDisabledFunc then | ||
element:setDisabled(isDisabledFunc()) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
function BCSettingsPage:onClick(state, element) | ||
local setting = element.bc_setting | ||
if setting == nil then return end | ||
setting:setIx(state) | ||
if TableUtility.contains({"lazyNPC","discountMode","hardMode"}, setting.name) then | ||
self:updateDisabled(element.parent) | ||
end | ||
SettingsEvent.sendEvent(setting) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?xml version="1.0" encoding="utf-8" standalone="no" ?> | ||
<!--===================================================================================================== | ||
BetterContracts GUI additions | ||
Purpose: Enhance ingame contracts menu with filterbox | ||
Author: Mmtrx, modified from FS22_Courseplay | ||
Copyright: Courseplay | ||
License: GNU GPL v3.0 | ||
Changelog: | ||
v1.2.6.0 30.11.2022 UI for all settings | ||
======================================================================================================--> | ||
<GUI name="BCsettings"> | ||
<GuiElement type="empty" profile="uiInGameMenuFrame"> | ||
<GuiElement type="empty" profile="ingameMenuFrameHeaderPanel"> | ||
<GuiElement type="bitmap" profile="menuHeaderIcon" size="64px 64px"/> | ||
<GuiElement type="text" profile="ingameMenuFrameHeaderText" id="header"/> | ||
</GuiElement> | ||
|
||
<GuiElement type="text" profile="settingsMenuSubtitle" id="subTitlePrefab"/> | ||
|
||
<GuiElement type="multiTextOption" profile="multiTextOptionSettings" id="multiTextOptionPrefab" onClick="onClick"> | ||
<GuiElement type="button" profile="multiTextOptionSettingsLeft" /> | ||
<GuiElement type="button" profile="multiTextOptionSettingsRight"/> | ||
<GuiElement type="text" profile="multiTextOptionSettingsText" /> | ||
<GuiElement type="text" profile="multiTextOptionSettingsTitle"/> | ||
<GuiElement type="bitmap" profile="multiTextOptionSettingsBg" /> | ||
<GuiElement type="text" profile="multiTextOptionSettingsTooltip"/> | ||
</GuiElement> | ||
|
||
<GuiElement type="empty" profile="ingameMenuSettingsBox" id="settingsContainer"> | ||
<GuiElement type="bitmap" profile="topScrollClipper" name="topClipper" /> | ||
<GuiElement type="bitmap" profile="bottomScrollClipper" name="bottomClipper" /> | ||
|
||
<GuiElement type="scrollingLayout" profile="ingameMenuSettingsLayout" id="boxLayout" topClipperElementName="topClipper" bottomClipperElementName="bottomClipper"> | ||
</GuiElement> | ||
</GuiElement> | ||
|
||
<GuiElement type="threePartBitmap" profile="verticalListSliderRightDocked"> | ||
<GuiElement type="slider" profile="verticalListSliderBar" dataElementId="boxLayout" handleFocus="false" /> | ||
</GuiElement> | ||
</GuiElement> | ||
</GUI> |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
<?xml version="1.0" encoding="utf-8" standalone="no"?> | ||
<l10n> | ||
<texts> | ||
<!-- Keys --> | ||
<text name = "input_MENU_EXTRA_3" text = "Melhores contratos: Detalhes Ligado/Desligado"/> | ||
<!-- Gui Buttons --> | ||
<text name="bc_hidden" text="Oculto: %d" /> | ||
<text name="bc_other" text="Outros" /> | ||
<text name="bc_new_contracts" text="Novos Contratos" /> | ||
<text name="bc_clear_contracts" text="Limpar Contratos" /> | ||
<text name="bc_detailsOff" text="Detalhes Desligado" /> | ||
<text name="bc_detailsOn" text="Detalhes Ligado" /> | ||
|
||
<!-- Hard mode --> | ||
<text name="bc_penalty" text="Penalidade" /> | ||
<text name="bc_warnTimeout" text="Por favor, conclua seu(s) %d contrato(s) na próxima hora, para evitar penalidades de contrato." /> | ||
<text name="bc_warnCancel" text=" A penalidade contratual será de pelo menos " /> | ||
|
||
<!-- discount mode --> | ||
<text name="bc_maxJobs" text="Você atingiu o desconto máximo para %s." /> | ||
<text name="bc_discount" text=" (%d%% desconto)" /> | ||
<text name="bc_discValue" text="%s concede a você %d %% desconto para futuras compras de campo." /> | ||
<!-- Display texts --> | ||
<text name="bc_harvest" text="Colheita de:" /> | ||
<text name="bc_leased" text="Alugado " /> | ||
<text name="bc_enoughMissions" text="Sua fazenda já tem o número máximo de contratos." /> | ||
|
||
<text name="SC_widhei" text="Largura/Altura máxima:" /> | ||
<text name="SC_worktim" text="Tempo Estimado:" /> | ||
<text name="SC_price" text="Preço:" /> | ||
<text name="SC_profpmin" text="Lucro/Minuto:" /> | ||
<text name="SC_sort" text="Ordenar por:" /> | ||
|
||
<text name="SC_field" text="Campo %d / %s" /> | ||
<text name="SC_fillType" text="Tipo de mercadoria:" /> | ||
<text name="SC_worked" text="Campo trabalhado:" /> | ||
<text name="SC_delivered" text="Entregue:" /> | ||
<text name="SC_deliver" text="Deve entregar:" /> | ||
<text name="SC_keep" text="Pode manter:" /> | ||
<text name="SC_profit" text="Lucro da colheita:" /> | ||
<text name="SC_profitSupply" text="Lucro:" /> | ||
<text name="SC_usage" text="Utilização:" /> | ||
<text name="SC_cost" text="Custo do material:" /> | ||
<text name="SC_togo" text="Deve ser entregue:" /> | ||
<text name="SC_timeleft" text="Tempo restante:" /> | ||
|
||
<!-- Sort button help text --> | ||
<text name="SC_sortCat" text="Tipo de missão" /> | ||
<text name="SC_sortProf" text="Lucro líquido" /> | ||
<text name="SC_sortpMin" text="Lucro por minuto" /> | ||
|
||
<!-- Settings Page (and v1.2.6.0 additions) --> | ||
<text name="bc_jobsCompleted" text="Jobs completed: %d" /> | ||
<text name="bc_leaseNotEnough" text="You need to complete %d more jobs for %s with own equipment, before you can borrow machines." /> | ||
<text name="bc_owner" text="Owner:" /> | ||
|
||
<text name="bc_settingsPage_title" text="Contract Settings" /> | ||
|
||
<text name="bc_baseSettings" text="Base Settings" /> | ||
<text name="bc_rewardMultiplier" text="Reward" /> | ||
<text name="bc_rewardMultiplier_tooltip" text="Adjust the rewards for contracts offered." /> | ||
<text name="bc_leaseMultiplier" text="Lease Cost" /> | ||
<text name="bc_leaseMultiplier_tooltip" text="Adjust the cost for borrowing equipment for contracts." /> | ||
<text name="bc_maxActive" text="Concurrently active contracts" /> | ||
<text name="bc_maxActive_tooltip" text="Max number of concurrently active contracts." /> | ||
<text name="bc_refreshMP" text="Permission contracts list" /> | ||
<text name="bc_refreshMP_tooltip" text="Who can delete / refresh contracts in an MP game." /> | ||
<text name="bc_debug" text="Debug Modus" /> | ||
<text name="bc_debug_tooltip" text="Prints info messages to the log if active. Can help to find bugs." /> | ||
|
||
<text name="bc_lazyNPC" text="Lazy Farmers" /> | ||
<text name="bc_mainSwitch" text="Activated" /> | ||
<text name="bc_active" text="Activated" /> | ||
<text name="bc_lazyNPC_tooltip" text="If active, NPC farmers more often skip work on their fields. So more contracts can be offered." /> | ||
<text name="bc_lazyNPCHarvest_tooltip" text="If active, NPC farmers do not harvest at all. Could result in a lot of work for you." /> | ||
<text name="bc_lazyNPCSow_tooltip" text="If active, NPC farmers perform sowing work more rarely and offer it as contracts instead." /> | ||
<text name="bc_lazyNPCPlow" text="Plow and Cultivate" /> | ||
<text name="bc_lazyNPCPlow_tooltip" text="If active, NPC farmers less often plow or cultivate on their own." /> | ||
<text name="bc_lazyNPCFertilize_tooltip" text="If active, NPC farmer perform fertilizing work more rarely and offer it as contracts instead." /> | ||
<text name="bc_lazyNPCWeed_tooltip" text="If active, NPC farmers fight weeds on thier fields more rarely, and instead offer spray and weeding contracts." /> | ||
|
||
<text name="bc_hardMode" text="Higher difficulty" /> | ||
<text name="bc_hardMode_tooltip" text="If active, all active contracts must be completed by end of month at the latest. Cancelling a contract will cost a penalty. Borrowing contract equipment is only unlocked after completing some jobs." /> | ||
<text name="bc_hardPenalty" text="Penalty" /> | ||
<text name="bc_hardPenalty_tooltip" text="Penalty amount for cancelled contract (in % of contract reward)." /> | ||
<text name="bc_hardLease" text="Unlock borrowing equipment" /> | ||
<text name="bc_hardLease_tooltip" text="Number of successful jobs for an NPC farmer, before they lend you their equipment." /> | ||
<text name="bc_hardExpire" text="Deadline" /> | ||
<text name="bc_hardExpire_tooltip" text="At the end of what time period all active contracts must be completed." /> | ||
|
||
<text name="bc_discountMode" text="Field purchase discount" /> | ||
<text name="bc_discountMode_tooltip" text="If active, an NPC farmer give a discount on farmland purchases. Discount increases with the number of competed jobs for this farmer." /> | ||
<text name="bc_discPerJob" text="Discount per completed contract" /> | ||
<text name="bc_discPerJob_tooltip" text="An NPC farmer increases their discount by this amount per job completed. Maximum discount cannot rise above 50%." /> | ||
<text name="bc_discMaxJobs" text="Number of discount-effective jobs" /> | ||
<text name="bc_discMaxJobs_tooltip" text="Can reduce the max discount, e.g. discount per contract = 11%, number of jobs = 3 -> max discount = 33%. Caution: Current number of jobs complete will decrease by this value on a farmland purchase." /> | ||
</texts> | ||
</l10n> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.