View Full Version : [PYTHON] Simple Game Clock Mod


homegrown
Nov 05, 2005, 03:49 PM
I like having the clock on, but I dislike how when I look up and want to know the game date, it's showing me the real time, and when I want to know the real time, it's showing me the game date. So I went looking...

This was wayyyy easier than I thought it would be. There are two sections of the CvMainInterface.py that needed to be looked at.


if (g_iTimeTextCounter >= 30.0): # 15 seconds
g_iTimeTextCounter = 0.0
self.updateTimeText(false)
screen.setLabel( "TimeText", "Background", g_szTimeText, CvUtil.FONT_RIGHT_JUSTIFY, xResolution - 56, 6, -0.3, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )
screen.show( "TimeText" )
elif (g_iTimeTextCounter >= 15.0): # Another 15 Seconds
self.updateTimeText(true)
screen.setLabel( "TimeText", "Background", g_szTimeText, CvUtil.FONT_RIGHT_JUSTIFY, xResolution - 56, 6, -0.3, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )
screen.show( "TimeText" )


I changed the first self.updateTimeText to (true)... telling it to display TimeText all the time.

The second section is where it determines what text to print...


def updateTimeText( self, bUseClockText ):

global g_szTimeText

ePlayer = gc.getGame().getActivePlayer()

if (CyUserProfile().isClockOn() and bUseClockText):
g_szTimeText = getClockText()
else:
g_szTimeText = unicode(CyGameTextMgr().getInterfaceTimeStr(ePlaye r))


If the clock is on, and we're supposed to be seeing the clock (which I changed above to always)...

g_szTimeText = getClockText() + " " + unicode(CyGameTextMgr().getInterfaceTimeStr(ePlaye r))

Here is a screenshot. http://home.houston.rr.com/homegrowns/images/homegrownclockmod.jpg

And a nifty zip (http://home.houston.rr.com/homegrowns/files/homegrownclockmod.zip). This just contains the CvMainInterface.py file. Place it in your My Documents/My Games/SM Civ 4/CustomAssets/python/screens folder.

The other thing that might be interesting to put there, would be the Elasped Game time, OR the time remaining until the alarm goes off... still pondering... maybe I'll take a poll. :D

Happy Civving!

Michael Nemo
Nov 05, 2005, 04:04 PM
Yes!!! This is absolutely the first thing I wanted to change, but I haven't looked at a programming language in years, so I was intimidated to do something about it...

THANK YOU!!!!!!!!!!!!!!! :D

CyberTyrant
Nov 05, 2005, 04:41 PM
Nice. Thanks homegrown. :goodjob:

vbraun
Nov 05, 2005, 04:42 PM
Very Nice!

kittenOFchaos
Nov 05, 2005, 05:06 PM
Brilliant, I too had this annoyance just lacked the abilities required to fix it :)

Firaxis will hopefully do that same!

YNCS
Nov 05, 2005, 06:21 PM
Thanks from me too.

Civrules
Nov 05, 2005, 06:54 PM
Very cool! :cool: Thanks!

Mr. Will
Nov 05, 2005, 07:07 PM
You are awesome.

Thanks.

HiroHito
Nov 05, 2005, 09:27 PM
thanks sir !!

Corey
Nov 06, 2005, 02:23 AM
Thank you!Very usefull....

civaddict098
Nov 06, 2005, 11:36 AM
thanks for this helpful mod, i allways have the same problem....

i would also realy like an elapsed time clock, that would be cool.

Kamakazie
Nov 06, 2005, 01:42 PM
thanks for this helpful mod, i allways have the same problem....

i would also realy like an elapsed time clock, that would be cool.
Seems like an easy process.

Is there a written API for all of these functions somewhere?

Phoenix_56721
Nov 06, 2005, 02:32 PM
Thanks works great!!!:goodjob: One (Noob modding) question by changing this in my interface will I have problems with playing online with other players that don't have this same interface? And what about changes I made to my ini file(no wonder movies for example) is that going to be a problem online? Thanks!

Gerikes
Nov 06, 2005, 11:25 PM
thanks for this helpful mod, i allways have the same problem....

i would also realy like an elapsed time clock, that would be cool.

Total time since this session started, or total time since the game started? I think total game time has it's own function..


CyGame().getMinutesPlayed()

As for session time, that might be a little more tricky. You'd probably have to store the result of getMinutesPlayed() or some other time function into a variable of your own, then to get the elapsed session time subtract this answer from the current getMinutesPlayed() or whatever time function is used.

Aeon221
Nov 07, 2005, 07:42 AM
:boggle: When did THAT directory pop into being! Good, solid, useful mod though

Ktulu
Nov 07, 2005, 01:40 PM
Awesome!

Ad another vote for the total game time addition.

Gunner
Nov 07, 2005, 04:37 PM
This is really great homegrown. This along with the improved F1 advisor are incredibly useful.

snepp
Nov 07, 2005, 05:29 PM
I hate to nitpick (the mod is great, the date/clock thing annoyed me to no end) but even tiny mods should have documentation. Doesn't need to be anything fancy, even if it's just installation instructions. Having the basic directory structure within the zip is a plus, though admittedly a bit of a hassle when you're only putting one file in it.

Thanks, between this and the domestic advisor, my Civ4 gaming is becoming less annoying and more enjoyable by the day.

carbonex
Nov 08, 2005, 07:02 AM
Dear god, this was a terrible problem. Thanks for the fix! I'm going to check out that domestic advisor mod next.

homegrown
Nov 08, 2005, 10:55 AM
Decided to work up a second flavor to this. My signature now contains a link to an All Clocks Mod that displays the real time, the elapsed game time (across all sessions, not just the current one), and the game date all at the same time.

And for the nitpicker, all the zips now have readme files. :p

Happy Civving!

Kinseek
Nov 08, 2005, 12:50 PM
I have a problem. With both this mod and the "All Clocks Mod", the clock will randomly dissapear and re-appear (I don`t know if it is time or the next turn or what triggers that, but it feels very random). The date text is always there. Anyone knows what might be causing it? (I haven`t touched any files before installing this mod)

BeefontheBone
Nov 08, 2005, 01:49 PM
I'd suggest just using the All Clocks mod - you don't need both of them running.

Kinseek
Nov 08, 2005, 02:32 PM
I`m not using both at the same time (which isn`t really even possible). I tried with both of them, separately, and they both gave the same results.

homegrown
Nov 08, 2005, 04:14 PM
I tried with both of them, separately, and they both gave the same results.
Yes, there is a 15 second delay from the start of the turn maybe(?) when only the game date displays.. then the real clock/elapsed timer kick in. It's very easy to change, but I kind of like the feel of it.

In the very first post, the first part of code, just change

if (g_iTimeTextCounter >= 30.0):
with
if (g_iTimeTextCounter >= 15.0:

mercurycs
Nov 08, 2005, 09:57 PM
I changed the 30 to a 15 yet i get a disappearing clock too. i cleared my cache and tried to start a new game too. on and off, on and off. i want the clock to stay and hang out for a bit. any help?

snepp
Nov 09, 2005, 01:18 PM
And for the nitpicker, all the zips now have readme files. :p

That would be me. :lol:

Thanks again for the excellent mod (and the documentation). :p

sinaarrgghh
Nov 10, 2005, 02:13 PM
Neither of those clock mods work for me. I have the improved domestic advisor and it works fine. Both of these screen mods are in the same place. I have cleared my cache. I have even followed your instructions for changing the delay (in case I was just being impatient!) but I still just get the standard game year displayed. Any help would be nice but thanks for the advisor anyways! :)

snepp
Nov 10, 2005, 02:14 PM
Neither of those clock mods work for me. I have the improved domestic advisor and it works fine. Both of these screen mods are in the same place. I have cleared my cache. I have even followed your instructions for changing the delay (in case I was just being impatient!) but I still just get the standard game year displayed. Any help would be nice but thanks for the advisor anyways! :)

Did you enable the clock in the options menu?

sinaarrgghh
Nov 10, 2005, 03:41 PM
Did you enable the clock in the options menu?

Errr... No! :blush: Man do I feel like an idiot! :lol: Thanks for that.

snepp
Nov 10, 2005, 04:41 PM
Errr... No! :blush: Man do I feel like an idiot! :lol: Thanks for that.

I asked that question right off, because I did the exact same thing. I probably cleared my cache and restarted the game a half-dozen times before I realized it. :lol:

1c0n
Nov 16, 2005, 09:35 AM
neither clock or domestic work for me, in custom assests folder, and yes my clock is on, and yes i did the same thing, restarted a couple times lol. i tried with and without the reaslism mod aswel, no good there either.
the clock isnt CRUCIAL to me as im windowed (to avoid CTD"S) but the domestic one is of great interest to me, so please help!!! :D

thanks

Methos
Nov 21, 2005, 07:02 PM
I'm having an interesting problem with this mod. I downloaded and installed it and when I loaded a game it came up with a black screen, informed me I had lost, and that the game was waiting for other civilizations. The only keys I could get to work were Ctr-L so I loaded a different game and got the same thing.

One thing of note, when I tried loading a saved game using Rhye's Earth 18 civ mod the game worked fine. The mod did not work but I assume thats due to different directories.

I loaded this file into the Screens directory as was stated. Prior I checked the directory and it was entirely empty. BTW, I downloaded your zipped file and did not make the changes myself. I'm not a programmer.

Any suggestions?

Underseer
Nov 27, 2005, 07:47 PM
Great! Thanks!

Oh, and bumpitty. ;)

Tubby Rower
Nov 28, 2005, 07:14 AM
homegrown & (others if you care)

I modified your mod slightly to also add the actual turn number just before the date. I'm at work now and can't check it out, but I'll post a screenie of it tonite unless someone beats me to it.

This is mainly requested by SGer's in order to only play 10 turns. It's rough trying to remember the dates when they changed since [c3c]

EDIT::::deleted due to idiocy

FexFX
Nov 28, 2005, 07:22 AM
Very Nice addition...Turn number!

I did a modification on this mod myself. As the above person reported, I had a problem with the clock not showing up for the first ~30 seconds of every turn.

My solution was to simply make it so there was no "off" state for the clock, so that at all times it would display both the time and the Year. Presto, the problem of the vanishing clock was solved!

As those who use this mod are unlikely to want the Clock to be turned off at any point this is a great solution!

I will have to add the Turn counter too now! That's just too cool!

lordwei
Nov 28, 2005, 07:45 AM
Bravo!!!!!!

Methos
Nov 28, 2005, 07:59 AM
This is mainly requested by SGer's in order to only play 10 turns. It's rough trying to remember the dates when they changed since [c3c]

Thanks, I've been getting tired of keeping track of turns. Plus I'm not for sure how many players have messed their turn count up out of confusion. Thanks again Tubby, this is much appreciated.:goodjob:

I did a modification on this mod myself. As the above person reported, I had a problem with the clock not showing up for the first ~30 seconds of every turn.

Do you mind stating how you did it? I suck at python though I am trying to learn it. Any help or explanations would be very appreciated.:)

Tubby Rower
Nov 28, 2005, 08:09 AM
deleted due to idiocy

Tubby Rower
Nov 28, 2005, 08:12 AM
deleted due to idiocy

Methos
Nov 28, 2005, 08:19 AM
Thanks again Tubby!:goodjob:

Tubby Rower
Nov 28, 2005, 02:09 PM
After testing my mods.... apparently they need a little tweaking.

I've deleted the references above to any mod I've made. I'll post something once I get it working. :blush:

Tubby Rower
Nov 28, 2005, 02:57 PM
I have a version that works in Single Player mode but for some reason it crashes civ4 when running it in Multiplayer mode. :hmm:

I'll continue to scrath my head and try things, but if anyone has any ideas. please come forward.

Tubby Rower
Nov 28, 2005, 03:18 PM
I think that my PBEM that I was using to test the multiplayer part was corrupt (bad Whomp!!). I tried a previous save and it opened fine.

here is my revision 1.2 to homegrown initial mod.

Installation

Unzip the contents to your My Documents/My Games/Sid Meiers Civilization 4/CustomAssets/python/screens folder.

The zip file contains 2 file

CvMainInterface.py
readme

Tubby's mod of Homegrowns Civilization 4 Game Clock Mod v.1.2

This modification displays the clock time and the game date at the same time, instead of flashing every 15 seconds.

Installation

Unzip the contents to your My Documents/My Games/Sid Meiers Civilization 4/CustomAssets/python/screens folder.

The zip file contains 1 file

CvMainInterface.py

revision 1.2:
added the turn number to the display
make the display always show the time


red highlighted is what I changed
def updateTimeText( self, bUseClockText ):

global g_szTimeText

ePlayer = gc.getGame().getActivePlayer()
iturn = gc.getGame().getGameTurn() + 1

if (true):
g_szTimeText = getClockText() + " (Turn %i) " % (iturn) + unicode(CyGameTextMgr().getInterfaceTimeStr(ePlaye r))
else:
g_szTimeText = getClockText() + " " + unicode(CyGameTextMgr().getInterfaceTimeStr(ePlaye r))

Tubby Rower
Nov 28, 2005, 08:32 PM
http://www.civfanatics.net/uploads10/turn.jpg

screenshot for the doubters

Pounder
Nov 29, 2005, 05:35 AM
http://www.civfanatics.net/uploads10/turn.jpg

screenshot for the doubters

Works great. Thanks.

FexFX
Nov 29, 2005, 08:09 AM
ROCK!
This is SWEET!

Methos
Nov 29, 2005, 06:51 PM
After testing my mods.... apparently they need a little tweaking.

Yeah, I was going to inform you that I had a, er... little problem with your mod. :lol: It showed the map and map only. Both the top bar and the bottom bar didn't show up.

Just ran the new one and everything works great. Thanks! :)

Tubby Rower
Nov 29, 2005, 07:35 PM
Yeah, I was going to inform you that I had a, er... little problem with your mod. :lol:at least you got that... I had to pull the power on mine it locked up so bad :D

abj9562
Nov 30, 2005, 10:47 PM
nice work!

lordwei
Dec 01, 2005, 09:29 AM
Great job!!!!!

Underseer
Dec 11, 2005, 09:50 AM
Just had to reinstall my game so... bumpitty!

Tubby Rower
Dec 11, 2005, 01:03 PM
Just had to reinstall my game so... bumpitty!because of this mod? if so, you mind giving an explanation of what was happening?

Wysdom
Dec 11, 2005, 05:33 PM
:king:

homegrown, you rock the casbah!

I'm so anal about the little details in my game interfaces, and this one was a huge pet peeve, a blight on otherwise blissful hours of Machiavellian maneuvering.

Thankyouthankyouthankyouthankyou!

Yours in perpetual adoration,

Wysdom :worship:

@rjen
Dec 12, 2005, 10:35 AM
My solution was to simply make it so there was no "off" state for the clock, so that at all times it would display both the time and the Year. Presto, the problem of the vanishing clock was solved!

As those who use this mod are unlikely to want the Clock to be turned off at any point this is a great solution!

Hi FexFX,

can you tell me and others with the 'disappearing clock problem' how you worked this out? How did you 'simply make it so there was no 'off' state for the clock?

thanks!

Tubby Rower
Dec 12, 2005, 10:38 AM
Hi FexFX,

can you tell me and others with the 'disappearing clock problem' how exactly you worked this out?

thanx!see post 43 (http://forums.civfanatics.com/showpost.php?p=3382175&postcount=43). If you don't want the turn number take that part out.

@rjen
Dec 12, 2005, 12:00 PM
Thanks Tubby Rower, I scrolled over your revision notes!
Keep up the good work! :goodjob:

NeverMind
Dec 15, 2005, 01:32 AM
Tubby Rower, very useful tweak! :thanx:

oagersnap
Dec 23, 2005, 06:04 AM
Tubby Rower, your clock doesn't work after I´ve installed version 1.52 of the game. Should I download and install it again, or will you make a new version of the mod?

Methos
Dec 23, 2005, 06:12 AM
That's odd. I haven't upgraded yet but I wouldn't think the patch would affect files in your Custom Assets folder.

Did you relace the mod with the original files located in the Assets folder or did you place them in the Custom Assets folder?

oagersnap
Dec 23, 2005, 06:52 AM
That's odd. I haven't upgraded yet but I wouldn't think the patch would affect files in your Custom Assets folder.

Did you relace the mod with the original files located in the Assets folder or did you place them in the Custom Assets folder?

I placed it in the exact place described in the post. My old games form before the patch have the modded clock, but if I start a new game, it has the original clock released with the game.

EDIT: Just checked the file, the code is edited so it should be Tubby Rowers clock, but it's still the original one. Perhaps I should just clear the cache.

Methos
Dec 23, 2005, 06:56 AM
Nice to know. I believe I'll move my mods before updating so they're not lost. Thanks.

Edit: Just reread your post and noticed the games from before working with the mod but new ones not. Anymore anytime I start CivIV I press Shift when loading. It's easier to load without the cache.

AstroCat
Dec 23, 2005, 07:10 AM
I noticed that CvMainInterface.py was updated in the patch. Would overriding this file with your older CvMainInterface.py cause any issues?

The Great Apple
Dec 23, 2005, 07:14 AM
Yes, it will mean the updates caused by the patch to this file won't show correctly. I'm not quite sure what these updates are, but just to be on the safe side I've applied Tubby Rower's clock to the 1.52 file.

There shouldn't be any bugs... probably.

Here it is:

AstroCat
Dec 23, 2005, 07:27 AM
Thanks. :)

Tubby Rower
Dec 23, 2005, 10:08 AM
Thanks Great Apple... I meant to do this earlier

oagersnap
Dec 23, 2005, 10:21 AM
Yes, it will mean the updates caused by the patch to this file won't show correctly. I'm not quite sure what these updates are, but just to be on the safe side I've applied Tubby Rower's clock to the 1.52 file.

There shouldn't be any bugs... probably.

Here it is:
It still goes in the civ4whatever/CustomAssets/python/screens folder, right?

Conquete
Dec 23, 2005, 06:45 PM
THANKS!!!!!
this helps A LOT!!

The Great Apple
Dec 23, 2005, 07:03 PM
It still goes in the civ4whatever/CustomAssets/python/screens folder, right?
Yes, it just replaces the old file.

I also made a very slight change in the logic. I don't think it will have any gameplay effect, it just trims out some un-needed code. (Previously the game was checking when the timer was at 15 and at 30, resetting at 30, and, apart from that, doing the same thing, now it just goes to 15 and resets)

Master Lexx
Dec 24, 2005, 06:58 AM
Can you please make it as addon to the original python files? I got something similar of the inquisitor mod. Only one small original file is overwritten and this calls other py files and in them there are all changes. So it is more compatible with newer patches and so.

Thanks

lordroy
Dec 24, 2005, 07:06 AM
It works fine in single player games, but doesn't work in multiplayer anymore for some reason. It used to work in multiplayer.


-=R=-

Dianthus
Jan 02, 2006, 11:34 AM
@homegrown/TubbyRower. We've stolen your code and put it into a HOF mod (see http://hof.civfanatics.net/civ4/mod.php). I say stole because I've just realised that I forgot to ask permission :blush:. I did make sure to give you credit though. I hope that's alright!

Dianthus
Jan 02, 2006, 11:36 AM
It works fine in single player games, but doesn't work in multiplayer anymore for some reason. It used to work in multiplayer.

One of the changes in 1.52 for single player games was that when the admin password is set the "My Documents\My Games\Sid Meier's Civilization 4\CustomAssets" folder is not used. I suspect (but don't know for sure) that this would apply to multiplayer games as well.

lordroy
Jan 02, 2006, 05:40 PM
One of the changes in 1.52 for single player games was that when the admin password is set the "My Documents\My Games\Sid Meier's Civilization 4\CustomAssets" folder is not used. I suspect (but don't know for sure) that this would apply to multiplayer games as well.


That doesnt make sense that it would work for one and not the other tho.


I use my computer with the admin account all the time. It is the only account on my computer.


I dont think this is the reason it does that.


-=R=-

Superhai
Jan 02, 2006, 09:02 PM
Hello all!

This got me on to the idea to modify the date line entirely. So I changed updateTimeText() from the previous mod to give me two things. Which era I am playing, and the year since my state religion was founded.


def updateTimeText( self, bUseClockText ):

global g_szTimeText

iSHEra = gc.getActivePlayer().getCurrentEra()
eSHReligion = gc.getActivePlayer().getStateReligion()
if (eSHReligion == -1):
eSHReligion = 1
if (gc.getGame().isReligionFounded(eSHReligion)):
iSHYearZero = gc.getGame().getTurnYear(gc.getGame().getReligionG ameTurnFounded(eSHReligion))
iSHDisplayYear = gc.getGame().getGameTurnYear() - iSHYearZero
g_szTimeText = getClockText() + " " + unicode(gc.getEraInfo(iSHEra).getDescription()) + " " + localText.getText("TXT_KEY_TIME_AD", (iSHDisplayYear, ()))
else:
g_szTimeText = getClockText() + " " + unicode(gc.getEraInfo(iSHEra).getDescription()) + " " + localText.getText("TXT_KEY_TIME_TURN", (gc.getGame().getGameTurn(), ()))




And if you have not a state religion, you will either get a date based on christianity (religion with index 1) or turns from start.

It is very basic and this is first time I makes anything with python but I have looked at other scripts and think this is fairly safe.

Another note is that the timelines and all other times will still be in the 'old' time, but although possible to do something about it, you would make bigger changes to the game run.

Tubby Rower
Jan 03, 2006, 06:37 AM
btw, Dianthius, I don't mind if you use my code...


IMO anyone who does mind should be working for a software company that has copyright protection. This game was meant to be moddable and people shouldn't feel as though they were ripped off by someone using their work. I enjoy this game and if it takes 10 people working off of each other's work to get a great mod out which everyone is happy with, we'll all be better in the long run. As long as people are given credit for their work, I don't think that they have any right to complain. Open source games are easy to compare the original file with the modded file and "reproduce" the results.


But thanks for the concern Dianthius. ;)

Caesium
Apr 15, 2006, 07:15 PM
Will there be an update to 1.61?

TheLopez
Apr 15, 2006, 08:07 PM
Caesium, in case this mod doesn't get updated, I have updated my Not Just Another Game Clock Mod to be compatible with the v1.61 patch which includes the functionality of this mod plus a lot more.

Caesium
Apr 16, 2006, 01:55 PM
TheLopez have thanks.
I hoped to get this one because I had some mods in my combined mod and with 1.61 there were only 3 or 4 mods I couldn't adapt to 1.61.

Methos
Apr 16, 2006, 02:25 PM
There's no need to update this mod. The patch includes a clock.

TheLopez
Apr 16, 2006, 03:25 PM
Methos, the clock was in there prior to the patch, the problem with it is that is it displayed as alternating text with the year. So for 15 sec the year is shown and for 15 sec the clock is shown. This mod moves the clock text over so both are displayed. With my mod you can do this, set the alternating time, etc.

Methos
Apr 17, 2006, 04:03 PM
Methos, the clock was in there prior to the patch, the problem with it is that is it displayed as alternating text with the year. So for 15 sec the year is shown and for 15 sec the clock is shown. This mod moves the clock text over so both are displayed. With my mod you can do this, set the alternating time, etc.

Apparently I need to clarify my statement, the patch now causes the clock to stay active the entire time. Either that or I just happened to look up everytime the clock was active. I used the mod from this thread until the patch, but obviously don't now.

TheLopez
Apr 17, 2006, 04:21 PM
Methos, the version of this mod is not compatible with the v1.61 patch, as far as I know. I have my own version of this mod that IS compatible. You might want to try my version until the version in this thread is updated.

Methos
Apr 17, 2006, 04:55 PM
Methos, the version of this mod is not compatible with the v1.61 patch, as far as I know. I have my own version of this mod that IS compatible. You might want to try my version until the version in this thread is updated.

I don't think your understanding what I've said. Unless I'm entirely mistaken, there is no need for a clock mod. Unless I'm just happening to look up every 15 seconds the clock is now there all the time.

X_MasterDave_X
Aug 17, 2006, 03:44 AM
Hi, is there an update for this mod for Civ4-Warlords.

I know, that i could activate the Game-Year and the Time simultan, but i want also to see the Number of Turns.....eg. (Turn 1/640).

Is there a mod for warlords who could do this ??

TheLopez
Aug 17, 2006, 06:48 AM
Yep, there is one. Try my Yet Another Game Clock Mod, the link can be found through my Component Library Thread. The link to it is in my sig.

X_MasterDave_X
Aug 17, 2006, 08:14 AM
Thanks TheLopez,

i found it....but in this tread is only a 1.61 compatible version. I need it for Warlords. Will this version work for Warlords too ??