[mod] Log changes

eotinb said:
Req (or anyone else who might know): know where I can find all the keyboard InputTypes? In CvEventManager.py there are some references to InputTypes.KB_T or whatever. I'm trying to find the InputType for PrintScreen some way other than trial and error (KB_PRTSCN? KB_PRINTSCREEN? etc.). This will allow me to coordinate with screenshots, which I really want to do -- I'm thinking after the screenshot you will get a prompt to input a caption and then there will be an entry in your log with the caption and the beginning of an img tag that you can complete after editing and hosting.

Sorry, eotinb. Didn't see your post until now.

class CvPythonExtensions.InputTypes(Boost.Python.enum)
| Method resolution order:
| CvPythonExtensions.InputTypes
| Boost.Python.enum
| __builtin__.int
| __builtin__.object
|
| Data and other attributes defined here:
|
| KB_0 = CvPythonExtensions.InputTypes.KB_0
|
| KB_1 = CvPythonExtensions.InputTypes.KB_1
|
| KB_2 = CvPythonExtensions.InputTypes.KB_2
|
| KB_3 = CvPythonExtensions.InputTypes.KB_3
|
| KB_4 = CvPythonExtensions.InputTypes.KB_4
|
| KB_5 = CvPythonExtensions.InputTypes.KB_5
|
| KB_6 = CvPythonExtensions.InputTypes.KB_6
|
| KB_7 = CvPythonExtensions.InputTypes.KB_7
|
| KB_8 = CvPythonExtensions.InputTypes.KB_8
|
| KB_9 = CvPythonExtensions.InputTypes.KB_9
|
| KB_A = CvPythonExtensions.InputTypes.KB_A
|
| KB_APOSTROPHE = CvPythonExtensions.InputTypes.KB_APOSTROPHE
|
| KB_AT = CvPythonExtensions.InputTypes.KB_AT
|
| KB_B = CvPythonExtensions.InputTypes.KB_B
|
| KB_BACKSLASH = CvPythonExtensions.InputTypes.KB_BACKSLASH
|
| KB_BACKSPACE = CvPythonExtensions.InputTypes.KB_BACKSPACE
|
| KB_C = CvPythonExtensions.InputTypes.KB_C
|
| KB_CAPSLOCK = CvPythonExtensions.InputTypes.KB_CAPSLOCK
|
| KB_COLON = CvPythonExtensions.InputTypes.KB_COLON
|
| KB_COMMA = CvPythonExtensions.InputTypes.KB_COMMA
|
| KB_D = CvPythonExtensions.InputTypes.KB_D
|
| KB_DELETE = CvPythonExtensions.InputTypes.KB_DELETE
|
| KB_DOWN = CvPythonExtensions.InputTypes.KB_DOWN
|
| KB_E = CvPythonExtensions.InputTypes.KB_E
|
| KB_END = CvPythonExtensions.InputTypes.KB_END
|
| KB_EQUALS = CvPythonExtensions.InputTypes.KB_EQUALS
|
| KB_ESCAPE = CvPythonExtensions.InputTypes.KB_ESCAPE
|
| KB_F = CvPythonExtensions.InputTypes.KB_F
|
| KB_F1 = CvPythonExtensions.InputTypes.KB_F1
|
| KB_F10 = CvPythonExtensions.InputTypes.KB_F10
|
| KB_F11 = CvPythonExtensions.InputTypes.KB_F11
|
| KB_F12 = CvPythonExtensions.InputTypes.KB_F12
|
| KB_F2 = CvPythonExtensions.InputTypes.KB_F2
|
| KB_F3 = CvPythonExtensions.InputTypes.KB_F3
|
| KB_F4 = CvPythonExtensions.InputTypes.KB_F4
|
| KB_F5 = CvPythonExtensions.InputTypes.KB_F5
|
| KB_F6 = CvPythonExtensions.InputTypes.KB_F6
|
| KB_F7 = CvPythonExtensions.InputTypes.KB_F7
|
| KB_F8 = CvPythonExtensions.InputTypes.KB_F8
|
| KB_F9 = CvPythonExtensions.InputTypes.KB_F9
|
| KB_G = CvPythonExtensions.InputTypes.KB_G
|
| KB_GRAVE = CvPythonExtensions.InputTypes.KB_GRAVE
|
| KB_H = CvPythonExtensions.InputTypes.KB_H
|
| KB_HOME = CvPythonExtensions.InputTypes.KB_HOME
|
| KB_I = CvPythonExtensions.InputTypes.KB_I
|
| KB_INSERT = CvPythonExtensions.InputTypes.KB_INSERT
|
| KB_J = CvPythonExtensions.InputTypes.KB_J
|
| KB_K = CvPythonExtensions.InputTypes.KB_K
|
| KB_L = CvPythonExtensions.InputTypes.KB_L
|
| KB_LALT = CvPythonExtensions.InputTypes.KB_LALT
|
| KB_LBRACKET = CvPythonExtensions.InputTypes.KB_LBRACKET
|
| KB_LCONTROL = CvPythonExtensions.InputTypes.KB_LCONTROL
|
| KB_LEFT = CvPythonExtensions.InputTypes.KB_LEFT
|
| KB_LSHIFT = CvPythonExtensions.InputTypes.KB_LSHIFT
|
| KB_M = CvPythonExtensions.InputTypes.KB_M
|
| KB_MINUS = CvPythonExtensions.InputTypes.KB_MINUS
|
| KB_N = CvPythonExtensions.InputTypes.KB_N
|
| KB_NUMLOCK = CvPythonExtensions.InputTypes.KB_NUMLOCK
|
| KB_NUMPAD0 = CvPythonExtensions.InputTypes.KB_NUMPAD0
|
| KB_NUMPAD1 = CvPythonExtensions.InputTypes.KB_NUMPAD1
|
| KB_NUMPAD2 = CvPythonExtensions.InputTypes.KB_NUMPAD2
|
| KB_NUMPAD3 = CvPythonExtensions.InputTypes.KB_NUMPAD3
|
| KB_NUMPAD4 = CvPythonExtensions.InputTypes.KB_NUMPAD4
|
| KB_NUMPAD5 = CvPythonExtensions.InputTypes.KB_NUMPAD5
|
| KB_NUMPAD6 = CvPythonExtensions.InputTypes.KB_NUMPAD6
|
| KB_NUMPAD7 = CvPythonExtensions.InputTypes.KB_NUMPAD7
|
| KB_NUMPAD8 = CvPythonExtensions.InputTypes.KB_NUMPAD8
|
| KB_NUMPAD9 = CvPythonExtensions.InputTypes.KB_NUMPAD9
|
| KB_NUMPADCOMMA = CvPythonExtensions.InputTypes.KB_NUMPADCOMMA
|
| KB_NUMPADENTER = CvPythonExtensions.InputTypes.KB_NUMPADENTER
|
| KB_NUMPADEQUALS = CvPythonExtensions.InputTypes.KB_NUMPADEQUALS
|
| KB_NUMPADMINUS = CvPythonExtensions.InputTypes.KB_NUMPADMINUS
|
| KB_NUMPADPERIOD = CvPythonExtensions.InputTypes.KB_NUMPADPERIOD
|
| KB_NUMPADPLUS = CvPythonExtensions.InputTypes.KB_NUMPADPLUS
|
| KB_NUMPADSLASH = CvPythonExtensions.InputTypes.KB_NUMPADSLASH
|
| KB_NUMPADSTAR = CvPythonExtensions.InputTypes.KB_NUMPADSTAR
|
| KB_O = CvPythonExtensions.InputTypes.KB_O
|
| KB_P = CvPythonExtensions.InputTypes.KB_P
|
| KB_PAUSE = CvPythonExtensions.InputTypes.KB_PAUSE
|
| KB_PERIOD = CvPythonExtensions.InputTypes.KB_PERIOD
|
| KB_PGDN = CvPythonExtensions.InputTypes.KB_PGDN
|
| KB_PGUP = CvPythonExtensions.InputTypes.KB_PGUP
|
| KB_Q = CvPythonExtensions.InputTypes.KB_Q
|
| KB_R = CvPythonExtensions.InputTypes.KB_R
|
| KB_RALT = CvPythonExtensions.InputTypes.KB_RALT
|
| KB_RBRACKET = CvPythonExtensions.InputTypes.KB_RBRACKET
|
| KB_RCONTROL = CvPythonExtensions.InputTypes.KB_RCONTROL
|
| KB_RETURN = CvPythonExtensions.InputTypes.KB_RETURN
|
| KB_RIGHT = CvPythonExtensions.InputTypes.KB_RIGHT
|
| KB_RSHIFT = CvPythonExtensions.InputTypes.KB_RSHIFT
|
| KB_S = CvPythonExtensions.InputTypes.KB_S
|
| KB_SCROLL = CvPythonExtensions.InputTypes.KB_SCROLL
|
| KB_SEMICOLON = CvPythonExtensions.InputTypes.KB_SEMICOLON
|
| KB_SLASH = CvPythonExtensions.InputTypes.KB_SLASH
|
| KB_SPACE = CvPythonExtensions.InputTypes.KB_SPACE
|
| KB_SYSRQ = CvPythonExtensions.InputTypes.KB_SYSRQ
|
| KB_T = CvPythonExtensions.InputTypes.KB_T
|
| KB_TAB = CvPythonExtensions.InputTypes.KB_TAB
|
| KB_U = CvPythonExtensions.InputTypes.KB_U
|
| KB_UNDERLINE = CvPythonExtensions.InputTypes.KB_UNDERLINE
|
| KB_UP = CvPythonExtensions.InputTypes.KB_UP
|
| KB_V = CvPythonExtensions.InputTypes.KB_V
|
| KB_VOLUMEDOWN = CvPythonExtensions.InputTypes.KB_VOLUMEDOWN
|
| KB_VOLUMEUP = CvPythonExtensions.InputTypes.KB_VOLUMEUP
|
| KB_W = CvPythonExtensions.InputTypes.KB_W
|
| KB_X = CvPythonExtensions.InputTypes.KB_X
|
| KB_Y = CvPythonExtensions.InputTypes.KB_Y
|
| KB_Z = CvPythonExtensions.InputTypes.KB_Z
|
| NUM_INPUT_TYPE = CvPythonExtensions.InputTypes.NUM_INPUT_TYPE
|
| __slots__ = ()
|
| values = {1: CvPythonExtensions.InputTypes.KB_ESCAPE, 2: CvPythonExten...

ED: took out unwanted parts.

Req
 
hIdDeN_eViL said:
in version 1.2, has CvEventManager.py been changed from v1.1

i ask this because i have merged your changes in v1.1 with another mod, and i need to know what has been changed from v1.1 to 1.2, so i don't have to go through copy and pasting all 30 sections.

thx

Hehe, this is why subclassing rules!

Convert, eotinb :mischief:. I know, I know. It's a lot of work. I'll see if I can convert it sometime in-between my DA mod, my upcoming mods, playing cIV, and RL :p.

Req
 
Requies said:
Hehe, this is why subclassing rules!

Convert, eotinb :mischief:. I know, I know. It's a lot of work. I'll see if I can convert it sometime in-between my DA mod, my upcoming mods, playing cIV, and RL :p.

Req

heh? did you accidently quote me, or am i missing something? (probably the latter)

anyway, i thought of another question.

with the logFile variable, would it still work if i change it to "autolog.html"?
opening the log file with notepad isnt real pretty especially with all the color codes. i thought if it were a html file, you could at least admire all the pretty colors when you open it :D.
 
hIdDeN_eViL said:
heh? did you accidently quote me, or am i missing something? (probably the latter)

anyway, i thought of another question.

with the logFile variable, would it still work if i change it to "autolog.html"?
opening the log file with notepad isnt real pretty especially with all the color codes. i thought if it were a html file, you could at least admire all the pretty colors when you open it :D.

Heh, the reason subclassing is great for this is that when you're working on a mod and trying to get the changes all you would have to do is just copy the file over. You wouldn't have to worry about cut and pasting all the changes in all the files that were modified because subclassing would just create NEW files.

So, for example. Instead of modifying CvEventInterface, eotinb, w/ subclassing, could create a CvLoggingEventInterface which you could then subclass with your own special class CvHiddenEvilEventInterface. And all you would need to do would be to get the new file and install it and modify CvScreensInterface (assuming you didn't want to alter one of the functions that CvLoggingEventInterface altered, but that check can be done easily) and it would inherit all the code of the superclass (CvLoggingEventInterface) unless you specifically overrode that function.

Also, about the html, I don't see why you couldn't save it as an html file since it doesn't say anything about naming the files specifically, but then again, I haven't played with the mod yet.

Req
 
Requies said:
Heh, the reason subclassing is great for this is that when you're working on a mod and trying to get the changes all you would have to do is just copy the file over. You wouldn't have to worry about cut and pasting all the changes in all the files that were modified because subclassing would just create NEW files.

So, for example. Instead of modifying CvEventInterface, eotinb, w/ subclassing, could create a CvLoggingEventInterface which you could then subclass with your own special class CvHiddenEvilEventInterface. And all you would need to do would be to get the new file and install it and modify CvScreensInterface (assuming you didn't want to alter one of the functions that CvLoggingEventInterface altered, but that check can be done easily) and it would inherit all the code of the superclass (CvLoggingEventInterface) unless you specifically overrode that function.

Also, about the html, I don't see why you couldn't save it as an html file since it doesn't say anything about naming the files specifically, but then again, I haven't played with the mod yet.

Req

:eek: :eek: i understood... maybe less than half of that. is subclassing like putting all the codes into a seperate file then simply refering to that file when needed??? is that the oversimplified version, or am i completely on the wrong track?

as for the html thing, i was thinking that it shouldn't matter either, because although the extention is different, it shouldn't make a difference when it is opened for appending. it would just be more convinient to open it as a html doc rather than a .txt file.

anyway, far far away from home atm, so won't be able to test for a longlong time.


edit: req, any chance you can tell me if CvEventManager has been changed?
 
hIdDeN_eViL said:
:eek: :eek: i understood... maybe less than half of that. is subclassing like putting all the codes into a seperate file then simply refering to that file when needed??? is that the oversimplified version, or am i completely on the wrong track?

as for the html thing, i was thinking that it shouldn't matter either, because although the extention is different, it shouldn't make a difference when it is opened for appending. it would just be more convinient to open it as a html doc rather than a .txt file.

This wiki entry probably explains it better than I would.

So, are you forced to save it as a .txt file? Or can you save it as a .html file? I thought you could just change the file type output, but then again, I could be wrong since I haven't played with it yet.

Req
 
Requies said:
This wiki entry probably explains it better than I would.

So, are you forced to save it as a .txt file? Or can you save it as a .html file? I thought you could just change the file type output, but then again, I could be wrong since I haven't played with it yet.

Req
dammit... cant visit wiki where i am (china) for some reason.

i am in no position to test anything.. i dont have access to civ4 at the moment. im just dling mods and merging them so that when i get back i dont have to spend time doing it.

the default filename variable is "autolog.txt" so if i change it to "autolog.html", it should save to exactly that filename. when appending, i assume it will still function like any other text file. of course im only assuming all of this...
 
hIdDeN_eViL said:
dammit... cant visit wiki where i am (china) for some reason.

i am in no position to test anything.. i dont have access to civ4 at the moment. im just dling mods and merging them so that when i get back i dont have to spend time doing it.

the default filename variable is "autolog.txt" so if i change it to "autolog.html", it should save to exactly that filename. when appending, i assume it will still function like any other text file. of course im only assuming all of this...

Ah, ok. Gotcha. Yes, it should work (assuming the html tags work appropriately), because all in all, html is really just text. It's just highly stylized text :D. Hmmmm, I think I've just described code in general :crazyeye:. Anyways, I'm sure eotinb will correct me, if I'm giving you bad advice on his specific mod, but from a programmers' perspective there should be no difference whatsoever between a txt file and an html file except that a browser will be able to "read" and show html code that it wouldn't in the txt file (in the txt file that html code would be just simply text).

And since I'm rambling on, I think I'll shut up now :D.

Req
 
Oh yeah, from the wiki entry:

In object-oriented programming, a subclass is a class that inherits some properties from its superclass.

You can usually think of the subclass as being "a kind of" its superclass, as in a "a Manx is a kind of cat", or "a square is a kind of rectangle":

* A cat has fur, four legs, and a tail
o A Manx cat does not have a tail, but has all of the other characteristics listed above
* A rectangle has four sides with lengths w and h
o A square has all of the characteristics of a rectangle; in addition, w = h

In this way, a subclass is a more specific version of its superclass; that is, the facts about the cat state what is generally true for all cats, even if some kinds of cats happen to have no tail. And while all rectangles have four sides, the square has the more restricted feature that all of its sides have the same length.

Don't confuse the subclass-superclass relationship with that of classes and instances. An "instance of cat" refers to one particular cat. The manx cat in the table is still a class — there are many instances of manx cats. And if a particular cat (an instance of the cat class) happen to have its tail bitten off by a fox, that does not change the cat class. It's just that particular cat that has changed.

Some software manuals refer to subclasses as derived classes.
 
hIdDeN_eViL said:
in version 1.2, has CvEventManager.py been changed from v1.1

i ask this because i have merged your changes in v1.1 with another mod, and i need to know what has been changed from v1.1 to 1.2, so i don't have to go through copy and pasting all 30 sections.
The only change is to the onGoodyReceived() function (I may be getting the name a bit wrong, but just search for "goody" and you'll find it).
 
On saving as html, the default save is as a txt file, but you can just change the extension to .html and go. You should change the "style" variable to whichever the value for html is (by the way, I didn't implement the color-coding in html, so if you change the style variable it will all be black text).
 
Req, thanks for the KB_XXX info -- that'll be a big help. As for subclassing, I certainly see your point. I actually went to do this but got stuck because I don't know where to import my file with the subclass.
 
eotinb said:
Req, thanks for the KB_XXX info -- that'll be a big help. As for subclassing, I certainly see your point. I actually went to do this but got stuck because I don't know where to import my file with the subclass.

Do you mean what files you want to import the subclass you created? If so, it depends upon what functionality you want. I believe CvEventInterface is imported at CvDawnofMan, CvMainInterface, and CvWorldBuilder in the Screens dir and CvGameInterface in the EntryPoints dir. I don't believe the WorldBuilder needs your logging functionality, but the others might (along with the obvious CvScreensInterface where you NEED to put it in). I guess it just depends where you need to call a function specific to your subclass. Otherwise, if Python implemented subclassing correctly, you SHOULDN'T have to import your class elsewhere.

For example, if CvMainInterface only uses the onKbdEvent function (hypothetically), then it should matter if you overload that function in the subclass. It should still work correctly. However, if you want it to call eotinbcustommadefunction function, then you would have to import your specific file.

Hmmm, it potentially seems like a non-trivial task. Anyways, if you need my help let me know.

Req
 
I found a bug, which only surfaces when a city changes hands between the AIs. It throws a Python exception because local variable message is not initialized before being used. Here is the code with the problem, in cvEventManager.

Code:
# autolog addition 25/30
#----------------------------------------------------------------------------------------------
        if (autolog.AUTO_LOG_CITY_OWNERSHIP and city.getOwner() == CyGame().getActivePlayer()):
            message = "%s lost" % (city.getName())
        self.log.write(5, message)
#----------------------------------------------------------------------------------------------

The solution is to indent the line starting with "self.log.write".
 
I got that message the other day too, but it was pretty early in the game so I didn't know what was going on.
 
Great stuff eotinb!! This should be used by all SG'ers.

Out of curiousity because I'm an idiot, with the colors can I adjust them to different websites? Tubby Rower and I have spoilers at CDZ and their color codes don't match.
 
Whomp said:
Great stuff eotinb!! This should be used by all SG'ers.

Out of curiousity because I'm an idiot, with the colors can I adjust them to different websites? Tubby Rower and I have spoilers at CDZ and their color codes don't match.

In autolog.py you could edit the color codes. Note in this example I had to replace '[' with '{' to keep the text from being interpreted as the actual colors...
Code:
            if (color == 1):
                self.blueOpenTag = '{color="RoyalBlue"]'
                self.blueCloseTag = '{/color]'
                self.greenOpenTag = '{color="Green"]'
                self.greenCloseTag = '{/color]'
                self.redOpenTag = '{color="Red"]'
                self.redCloseTag = '{/color]'
                self.orangeOpenTag = '{color="DarkOrange"]'
                self.orangeCloseTag = '{/color]'
                self.purpleOpenTag = '{color="Purple"]'
                self.purpleCloseTag = '{/color]'
                self.brownOpenTag = '{color="Brown"]'
                self.brownCloseTag = '{/color]'
                self.yellowOpenTag = '{color="Yellow"]'
                self.yellowCloseTag = '{/color]'

Alternatively, open the output file in a text editor, and use find/replace to put in the color codes you need. This way you don't need to edit the autolog.py file to swap between CFC and CDG colors. Another idea is to define both and have a popup during startup ask which set you want to use.
 
eotinb said:
The only change is to the onGoodyReceived() function (I may be getting the name a bit wrong, but just search for "goody" and you'll find it).
thx. much easier now:goodjob:

eotinb said:
(by the way, I didn't implement the color-coding in html, so if you change the style variable it will all be black text)
:cry: :cry: :cry:
eagerly awaiting release with html color codes.
 
Back
Top Bottom