View Full Version : Missing .py files
weakciv Oct 31, 2005, 12:55 PM Well maybe my title is not completely correct but I cant seem to find them.
Anyway, looking through some of the .py files I find that one of the functions I am looking for comes from an "import from ... *". The problem is that I cant seem to find the "..." file it is importing from.
Unfortunatly I am at work right now and am not 100% sure of the file name. I am fairly sure that it was CvPythonExtentions. I was never able to find that file. The reason I wanted to see it was that I wanted to know what each of the arguments were for the function I was looking at.
Any help would be appreciated.
rowr Oct 31, 2005, 04:35 PM I think the module that you can't find is actually what's exported by the civilization C/Python interface from CvGameCore.dll
weakciv Oct 31, 2005, 06:55 PM any idea how to look at a file like that?
Jon Shafer Oct 31, 2005, 06:58 PM Which file?
If it's CvPythonExtensions then rowr is correct. I think there's a way to make the game output a massive help list of all the functions available from the game that are available through that file but I forget how to do it... I'll see if I can figure it out. It's actually a VERY important file.
weakciv Oct 31, 2005, 07:23 PM Which file?
If it's CvPythonExtensions then rowr is correct. I think there's a way to make the game output a massive help list of all the functions available from the game that are available through that file but I forget how to do it... I'll see if I can figure it out. It's actually a VERY important file.
Ok let me get specific. I am looking for the code associated with the "mouse over" handling. (ie when you get the information about a tile.)
I started with the CvMainInterface.py file and found this:
# Help Text Area
screen.setHelpTextArea( 350, FontTypes.SMALL_FONT, 7, yResolution - 172, -0.1, False, "", True, False, CvUtil.FONT_LEFT_JUSTIFY, 150 )
Ok so "setHelpTextArea" is a function of "screen". So let me find what "screen" is. I back up in the code and shortly above I find this:
screen = CyGInterfaceScreen( "MainInterface", CvScreenEnums.MAIN_INTERFACE )
Ok, looks like "screen" is an instance of "CyGInterfaceScreen". I look through the file I am in and do not find the def of CyGInterfaceScreen. So I begin looking for the import of it. Because it was not preceded by a parent reference (like screen.setHelpTextArea) I know it must be part of a "from ... import *". The only one I find is:
from CvPythonExtensions import *
So I begin hunting for CvPythonExtensions because I would like to know what the arguments mean for the setHelpTextArea function in CyGInterfaceScreen.
Jon Shafer Oct 31, 2005, 07:32 PM Yep, that's CvPythonExtensions for you...
Try this:
CvAppInterface.py
Set PythonHelp=0 from 0 to 1. Run the game (with Python installed). There should be a file called CvPythonExtensions.hlp.txt in your logs folder. If you need any help after that let me know. ;)
weakciv Oct 31, 2005, 07:46 PM I have python installed (not boost python) and after changing PythonHelp to 1 I got a "failed initializing python" message. does it matter what python you have installed?
Jon Shafer Oct 31, 2005, 07:56 PM Hmmmm... so it seems.
There's a problem with the function. Sorry, I'll need more time to look into this. I'll try to have an answer for you tomorrow. In the meantime, you can ask me which functions you need the list of arguments for.
vorius Oct 31, 2005, 08:00 PM Hmm, is it possible for you to rar up your copy of CvPythonExtensions.hlp.txt file and attach it to the forum here? Assuming you have that file generated, of course ...
weakciv Oct 31, 2005, 08:01 PM Trip,
I was able to get the file created by following this (http://forums.civfanatics.com/showpost.php?p=3242527&postcount=465) from GBM.
Im looking into it now.
vorius Oct 31, 2005, 08:04 PM Nice, and the file is attached there :)
Jon Shafer Oct 31, 2005, 08:04 PM Vorius: I would have, had it not been for the fact that it's not working here either and the most recent version of it that I might have would be over half a year old and excessively out of date. ;)
It seems that weakciv has found a way around this problem though! What thread is that weakciv? That should probably be posted in a stickied thread in this forum... all I can see is the post, not the thread.
weakciv Oct 31, 2005, 08:05 PM ok looking at the arguments for setHelpTextArea
( float fWidth, FontTypes eFont, float fX, float fY, float fZ, bool bFloating, string szArtFile, bool bExpandRight, bool bExpandDown, uint uiFlags, int iMinWidth )
To move the location of the Help Text I need to set the "fX" , "fY" (and maybe "fZ") arguments to where I want the new location, correct?
weakciv Oct 31, 2005, 08:06 PM it is GBMs stickied Mod Thread.
Jon Shafer Oct 31, 2005, 08:07 PM Yes, you want the X and Y different. I'm not sure Z matters in this situation.
weakciv Oct 31, 2005, 08:15 PM ok (rubs hands together) now to identify the X,Y of the mouse pointer ....
Jon Shafer Oct 31, 2005, 08:17 PM Uhhh... Hmmm...
Good luck. I haven't been able to find it myself. ;)
weakciv Oct 31, 2005, 08:25 PM found a function called getMousePos(). description says returns mouse coordinates.
Jon Shafer Oct 31, 2005, 08:42 PM Cool. :goodjob:
What class is that in? :mischief:
Locutus Oct 31, 2005, 09:28 PM I posted thread here with some Python info, including a link to an easy-to-naviate HTML version of the API Reference that l made, but noone cared apparently because it dropped like a brick. I can't find it now, but the same thread on Apolyton was much better received: http://apolyton.net/forums/showthread.php?s=&threadid=140611
weakciv Oct 31, 2005, 10:28 PM Yes Locutus, I found that and made it a favorite. but the info there for the CyGInterfaceScreen does not list the arguments for its functions. I look forward to when the whole API is updated.
weakciv Nov 04, 2005, 07:58 AM Uhhh... Hmmm...
Good luck. I haven't been able to find it myself. ;)
Some nice information I found is that the arguments list passed through the EventManager contains mx, my, px, py. (and a few others) I found that mx, my are Mouse X,Y and that px, py are Plot X,Y. Mouse X,Y is (drum roll) the location of your mouse. and Plot X,Y is the location of the selected Plot. Plot X,Y could be -1,-1 which means nothing is selected. (i need to verify that last statement)
WildWeazel Nov 04, 2005, 04:29 PM It seems that weakciv has found a way around this problem though! What thread is that weakciv? That should probably be posted in a stickied thread in this forum... all I can see is the post, not the thread.
You can click the thread name at the top to see the full thread. The thread is a sticky, but the file is buried in the 24th page.
@Locutus: I linked to your API from the Modder's Guide, so at least somebody can find it here if they need to.
Good work, weakciv. :)
WildWeazel Nov 05, 2005, 12:04 PM It sounds like it should work if you import the class CyInterface and use getMousePos() to return the coords, it should work. Does getMousePos() return both values together?
WildWeazel Nov 05, 2005, 04:28 PM I've been doing some digging. I tried something but of course it didn't work, since I don't really know Python. But I think I'm on the right track.
In CvMainInterface you import CyInterface and create an instance of it(?). This class has the function (method?) getMousePos(), which returns POINT object. POINT has 2 attributes- int x and int y, which in this case will correspond to the location of the cursor. What I don't know is how to access those ints. If you create a CyInterface called screen_interface or whatever, then "mouse = screen_interface.getMousePos()" would create a POINT called mouse, right? But then what? mouse.x and mouse.y? POINT doesn't have any functions listed in the API, just those 2 ints.
FWIW, according to the online API, CyInterface will not be included in the SDK.
weakciv Nov 05, 2005, 06:48 PM hmmm I havent messed with that part yet. Ill give it a try.
weakciv Nov 05, 2005, 07:31 PM OK THANK YOU!!!!!!
Major step forward. CyInterface is imported when the
from CvPythonExtentions import *
statement is performed.
Looking at how CyInterface is used I found that this is how to get the x and y values:
# direct reference
CyInterface().getMousePos().x
# or assigned to a variable
Mx = CyInterface().getMousePos().x
Now I have a few bugs (like blinking and missing text) to address. But the text area now moves with the mouse.
Oh, I also have to put in logic to make sure the text area doesnt display off the screen too.
WildWeazel Nov 05, 2005, 08:02 PM hmm... that's different. It makes sense though.
|
|