Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Dawn of Man screen #67

Merged
merged 4 commits into from
Oct 6, 2024
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
3 changes: 2 additions & 1 deletion Assets/Python/Rise.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from Core import get_scenario_start_turn, game
import CvScreensInterface
from Events import handler


# @handler("BeginGameTurn")
@handler("BeginGameTurn")
def showDawnOfMan(iGameTurn):
if iGameTurn == get_scenario_start_turn() and game.getAIAutoPlay() > 0:
CvScreensInterface.dawnOfMan.interfaceScreen()
150 changes: 57 additions & 93 deletions Assets/Python/screens/CvDawnOfMan.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
## Copyright Firaxis Games 2005

import math
from Core import civilization, text, turn, get_scenario_start_turn
from Core import civilization, human, text, get_scenario_start_turn, turns, game
import CvUtil
from CvPythonExtensions import *

Expand Down Expand Up @@ -32,26 +32,24 @@ def __init__(self, iScreenID):
self.W_SCREEN = 1024
self.H_SCREEN = 768

self.X_MAIN_PANEL = 238 # position of the main panel's top-left corner: pixels from left side of the screen
self.Y_MAIN_PANEL = 180 # pixels from top of the screen
self.W_MAIN_PANEL = 556 # number of pixels wide
self.H_MAIN_PANEL = 355 # number of pixels height
self.X_MAIN_PANEL = 250
self.Y_MAIN_PANEL = 190
self.W_MAIN_PANEL = 550
self.H_MAIN_PANEL = 350

self.iMarginSpace = 15

self.X_HEADER_PANEL = self.X_MAIN_PANEL + self.iMarginSpace
self.Y_HEADER_PANEL = self.Y_MAIN_PANEL + 10 # self.iMarginSpace
self.Y_HEADER_PANEL = self.Y_MAIN_PANEL + self.iMarginSpace
self.W_HEADER_PANEL = self.W_MAIN_PANEL - (self.iMarginSpace * 2)
self.H_HEADER_PANEL = self.H_MAIN_PANEL - 146 # int(self.H_MAIN_PANEL * (2.0 / 5.0))
self.H_HEADER_PANEL = int(self.H_MAIN_PANEL * (2.0 / 5.0))

self.X_LEADER_ICON = self.X_HEADER_PANEL + self.iMarginSpace
self.Y_LEADER_ICON = self.Y_HEADER_PANEL + self.iMarginSpace
self.H_LEADER_ICON = self.H_HEADER_PANEL - (15 * 2) # 140
self.W_LEADER_ICON = int(self.H_LEADER_ICON / 1.272727) # 110
self.H_LEADER_ICON = self.H_HEADER_PANEL - (15 * 2)
self.W_LEADER_ICON = int(self.H_LEADER_ICON / 1.272727)

self.X_LEADER_TITLE_TEXT = (
505 # iXHeaderPanelRemainingAfterLeader + (iWHeaderPanelRemainingAfterLeader / 2)
)
self.X_LEADER_TITLE_TEXT = 505
self.Y_LEADER_TITLE_TEXT = self.Y_HEADER_PANEL + self.iMarginSpace + 6
self.W_LEADER_TITLE_TEXT = self.W_HEADER_PANEL / 3 + 10
self.H_LEADER_TITLE_TEXT = self.H_HEADER_PANEL / 2
Expand All @@ -61,38 +59,31 @@ def __init__(self, iScreenID):
self.Y_FANCY_ICON = self.Y_LEADER_TITLE_TEXT - 6
self.WH_FANCY_ICON = 64

self.X_STATS_TEXT = (
self.X_FANCY_ICON1
) # + self.W_LEADER_ICON + (self.iMarginSpace * 2) + 5
self.X_STATS_TEXT = self.X_FANCY_ICON1
self.Y_STATS_TEXT = self.Y_LEADER_TITLE_TEXT + 75
self.W_STATS_TEXT = int(self.W_HEADER_PANEL * (5.25 / 7.0))
self.H_STATS_TEXT = int(self.H_HEADER_PANEL * (2.25 / 5.0))

self.X_TEXT_PANEL = self.X_HEADER_PANEL
self.Y_TEXT_PANEL = (
self.Y_HEADER_PANEL + self.iMarginSpace
) # 10 is the fudge factor #self.Y_HEADER_PANEL + self.H_HEADER_PANEL + self.iMarginSpace - 10 self.W_TEXT_PANEL = self.W_HEADER_PANEL
self.Y_TEXT_PANEL = self.Y_HEADER_PANEL + self.iMarginSpace
self.W_TEXT_PANEL = self.W_HEADER_PANEL
self.H_TEXT_PANEL = (
self.H_MAIN_PANEL - 32
) # (self.iMarginSpace * 3) + 10 #10 is the fudge factor
self.iTEXT_PANEL_MARGIN = 40 # from the top of the header panel
self.H_TEXT_PANEL = self.H_MAIN_PANEL - (self.iMarginSpace * 3) + 10
self.iTEXT_PANEL_MARGIN = 35

self.X_EXIT = 456 # self.X_MAIN_PANEL + self.W_MAIN_PANEL/2 - self.W_EXIT/2
self.Y_EXIT = self.Y_MAIN_PANEL + 307 # const = main panel height - 48
self.X_EXIT = 460
self.Y_EXIT = self.Y_MAIN_PANEL + 290
self.W_EXIT = 120
self.H_EXIT = 30

def interfaceScreen(self):
"Use a popup to display the opening text"
self.iLastTurn = -1
if CyGame().isPitbossHost():
return

self.player = gc.getPlayer(gc.getGame().getActivePlayer())
self.EXIT_TEXT = text("TXT_KEY_SCREEN_CONTINUE")

# Create screen

screen = CyGInterfaceScreen("CvDawnOfMan", self.iScreenID)
screen.showScreen(PopupStates.POPUPSTATE_QUEUED, False)
screen.showWindowBackground(False)
Expand All @@ -104,12 +95,7 @@ def interfaceScreen(self):
)
screen.enableWorldSounds(False)

# Create panels

# Main
szMainPanel = "DawnOfManMainPanel"

# Top
screen.addPanel(
szMainPanel,
"",
Expand All @@ -122,7 +108,7 @@ def interfaceScreen(self):
self.H_MAIN_PANEL,
PanelStyles.PANEL_STYLE_MAIN,
)
# Bottom

szTextPanel = "DawnOfManTextPanel"
screen.addPanel(
szTextPanel,
Expand Down Expand Up @@ -153,18 +139,15 @@ def interfaceScreen(self):
-1,
)

##Rhye - begin
pActivePlayer = gc.getPlayer(CyGame().getActivePlayer())
# Leoreth: imported individual texts from Sword of Islam (edead)
bodyString = getDawnOfManText(human())

bodyString = getDawnOfManText(CyGame().getActiveTeam())

# Progress bar position (top left corner, width, height) #X coordinate: self.X_MAIN_PANEL + self.W_MAIN_PANEL/2 - Progress bar width/2
screen.addStackedBarGFC(
"ProgressBar",
271,
425,
490,
35,
300,
400,
435,
40,
InfoBarTypes.NUM_INFOBAR_TYPES,
WidgetTypes.WIDGET_GENERAL,
-1,
Expand All @@ -186,16 +169,14 @@ def interfaceScreen(self):
screen.setStackedBarColors(
"ProgressBar", InfoBarTypes.INFOBAR_EMPTY, gc.getInfoTypeForString("COLOR_EMPTY")
)
self.iTurnsRemaining = -1

##Rhye - end
screen.addMultilineText(
"BodyText",
bodyString,
self.X_TEXT_PANEL + self.iMarginSpace,
self.Y_TEXT_PANEL + self.iMarginSpace + self.iTEXT_PANEL_MARGIN,
self.W_TEXT_PANEL - (self.iMarginSpace * 2),
self.H_TEXT_PANEL - (self.iMarginSpace * 2) - 139,
self.H_TEXT_PANEL - (self.iMarginSpace * 2) - 165,
WidgetTypes.WIDGET_GENERAL,
-1,
-1,
Expand All @@ -215,7 +196,7 @@ def interfaceScreen(self):
-1,
ButtonStyles.BUTTON_STYLE_STANDARD,
)
screen.hide("Exit") # Rhye
screen.hide("Exit")

pActivePlayer = gc.getPlayer(CyGame().getActivePlayer())
pLeaderHeadInfo = gc.getLeaderHeadInfo(pActivePlayer.getLeaderType())
Expand All @@ -227,62 +208,45 @@ def handleInput(self, inputClass):
return 0

def update(self, fDelta):
iGameTurn = game.getGameTurn()

##Rhye - begin
if civilization(CyGame().getActiveTeam()).date.birth <= get_scenario_start_turn():
screen = CyGInterfaceScreen("CvLoadingScreen", self.iScreenID)
screen.setBarPercentage("ProgressBar", InfoBarTypes.INFOBAR_STORED, 1)
screen.setLabel(
"Text",
"",
text("TXT_KEY_AUTOPLAY_TURNS_REMAINING", 0),
CvUtil.FONT_CENTER_JUSTIFY,
516,
465,
0,
FontTypes.GAME_FONT,
WidgetTypes.WIDGET_GENERAL,
-1,
-1,
)
screen.show("Exit") # Rhye
else:
iGameTurn = turn()
if iGameTurn <= self.iLastTurn:
return

iNumAutoPlayTurns = civilization(CyGame().getActiveTeam()).date.birth
iNumTurnsRemaining = iNumAutoPlayTurns - iGameTurn
self.iLastTurn = iGameTurn

screen = CyGInterfaceScreen("CvLoadingScreen", self.iScreenID)
iTotalAutoplay = civilization().date.birth - get_scenario_start_turn()

exponent = 1 + iNumAutoPlayTurns / 190
# Absinthe: for all scenarios:
screen.setBarPercentage(
"ProgressBar",
InfoBarTypes.INFOBAR_STORED,
float(math.pow(iGameTurn - get_scenario_start_turn(), exponent))
/ float(math.pow(iNumAutoPlayTurns - get_scenario_start_turn(), exponent)),
)
screen.setLabel(
"Text",
"",
text("TXT_KEY_AUTOPLAY_TURNS_REMAINING", iNumTurnsRemaining),
CvUtil.FONT_CENTER_JUSTIFY,
514,
465,
0,
FontTypes.GAME_FONT,
WidgetTypes.WIDGET_GENERAL,
-1,
-1,
iAutoplayRemaining = game.getAIAutoPlay()
iAutoplayElapsed = iTotalAutoplay - iAutoplayRemaining

if iAutoplayRemaining > 0:
exponent = 1 + 1.0 * iTotalAutoplay / turns(190)
fBarPercentage = float(math.pow(iAutoplayElapsed, exponent)) / float(
math.pow(iTotalAutoplay, exponent)
)
if iNumTurnsRemaining <= 0: # Rhye
screen.show("Exit") # Rhye
else:
fBarPercentage = 1.0

return
screen = CyGInterfaceScreen("CvLoadingScreen", self.iScreenID)
screen.setBarPercentage("ProgressBar", InfoBarTypes.INFOBAR_STORED, fBarPercentage)
screen.setLabel(
"Text",
"",
text("TXT_KEY_AUTOPLAY_TURNS_REMAINING", iAutoplayRemaining),
CvUtil.FONT_CENTER_JUSTIFY,
530,
445,
0,
FontTypes.GAME_FONT,
WidgetTypes.WIDGET_GENERAL,
-1,
-1,
)

##Rhye - end
if iAutoplayRemaining <= 0:
screen.show("Exit")

def onClose(self):
# Absinthe: do not play the initial RFC song on start - might even lead to sound selection issues
CyInterface().setSoundSelectionReady(True)
return 0
46 changes: 28 additions & 18 deletions Assets/Python/screens/ScreensHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@
import CvUtil
import PyHelpers
import Popup as PyPopup
from Core import get_data_from_upside_down_map, human, player, text
from Core import (
civilization,
get_data_from_upside_down_map,
get_scenario_start_turn,
human,
player,
text,
)
from MiscData import MODNET_EVENTS
from CityMapData import CITIES_MAP
from Events import events, handler
Expand Down Expand Up @@ -159,24 +166,27 @@ def onLoadGame():
def onGameStart():
# Rhye - Dawn of Man must appear in late starts too
# Duplicate with Assets/Python/Contrib/CvAllErasDawnOfManScreenEventManager.py
if (
gc.getGame().getStartEra() == gc.getDefineINT("STANDARD_ERA")
or gc.getGame().isOption(GameOptionTypes.GAMEOPTION_ADVANCED_START)
) and player().isAlive():
popupInfo = CyPopupInfo()
popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
popupInfo.setText(u"showDawnOfMan")
popupInfo.addPopup(human())
if gc.getGame().getStartEra() == gc.getDefineINT("STANDARD_ERA") or gc.getGame().isOption(
GameOptionTypes.GAMEOPTION_ADVANCED_START
):
if civilization().date.birth <= get_scenario_start_turn():
popupInfo = CyPopupInfo()
popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
popupInfo.setText(u"showDawnOfMan")
popupInfo.addPopup(human())
else:
CyInterface().setSoundSelectionReady(True)

if gc.getGame().isPbem() and player().isAlive():
popupInfo = CyPopupInfo()
popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_DETAILS)
popupInfo.setOption1(True)
popupInfo.addPopup(human())

CvAdvisorUtils.resetNoLiberateCities()
CyInterface().setSoundSelectionReady(true)

if gc.getGame().isPbem():
for iPlayer in range(gc.getMAX_PLAYERS()):
player = gc.getPlayer(iPlayer)
if player.isAlive() and player.isHuman():
popupInfo = CyPopupInfo()
popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_DETAILS)
popupInfo.setOption1(true)
popupInfo.addPopup(iPlayer)

CvAdvisorUtils.resetNoLiberateCities()


@handler("BeginGameTurn")
Expand Down
2 changes: 1 addition & 1 deletion Assets/XML/GlobalDefinesVersion.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
<Civ4Defines xmlns="x-schema:CIV4GlobalDefinesSchema.xml">
<Define>
<DefineName>RFCE_MOD_VERSION</DefineName>
<DefineTextVal>1.6.5-3</DefineTextVal>
<DefineTextVal>1.6.5-4</DefineTextVal>
</Define>
</Civ4Defines>
1 change: 1 addition & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ v1.6.6:
- Can't trade city with plague
- No financial trouble in the first 5 turns after spawn for AI
- Autoplay standby behavior and look has been improved (no more flashing when autoplay is actived)
- Improve Dawn of Man screen

v1.6.5: This release adds BUG and BULL mod

Expand Down
Loading