In-game python browser

arcticnightwolf

Emperor
Joined
Jun 8, 2008
Messages
1,301
InGame Python Browser
----------------------------------------
compatible with .36Beta LeadersEnhanced, however porting to somewhere else should be easy

Goal of this modmodmod is to make easy access to python in case you don't know (or understand) ability of some spell/unit/etc ... it will take some time to achieve this goal, but i trust myself, that i can do this ... :D

(Second goal is to kill my boredom ... :D)

http://forums.civfanatics.com/downloads.php?do=file&id=12862
(( there's major bug which prevents loading files ))


Spoiler InterfaceIcon :

Spoiler ScreenShots :



Spoiler old :



well, you can use this code in your mods now, but I strongly advise you to wait - there's loots of work to do and code needs to be revised and commented
( and if you use it, send me please message and write me to list of contributors .. :) )
 

Attachments

  • interface_icon.png
    interface_icon.png
    7.4 KB · Views: 84
  • selectdef.png
    selectdef.png
    186.5 KB · Views: 116
  • selectfile.png
    selectfile.png
    176.7 KB · Views: 73
  • v2_selectPY.png
    v2_selectPY.png
    169.4 KB · Views: 371
  • v2_selectXML.png
    v2_selectXML.png
    188.9 KB · Views: 339
  • v2_all.png
    v2_all.png
    143.8 KB · Views: 327
changelog

in progress:
- browsing through code by entities (ie Unit -> Avail. spells, Requirements; Spell -> PyReq, PyEffect, ...)

v002:
- code commented
- most of widget's IDs and locations moved to constants
- changed design (4 dropdown menus)
- XML support
- browsing XML and Python directories and subdirectories
- non-1024x768 screen support
- magical "ALL" button which shows all XML and python files at once in code table - takes 40 seconds to load :D:D

v001:
- main core of this project
- new icon next to unit_statistics icon (see below)
- can open python files in /assets/python/.
- allow user to browse through definitions (def)

to do:
- warping lines to next line
- and maybe in far future: edit code (( it would require UAC permission or changing sharing settings ))
 
Holy hell! Now if only you could edit the code from in-game.... ;)

I think I may have to steal this for my own mod, if you don't mind. :lol:

well ... there's loots of work to be done ... i advise you to wait ... (and since i have vacation from school, it shouldn't take long)

Opera said:
thanks .. :)

---------------------------------

BTW, don't you know whether there's function which returns PyRequirement and PyResult attribute ?? (ie i want to get that string "spellBlizard(caster)" from SPELL_BLIZZARD without searching through XML)
 
well ... there's loots of work to be done ... i advise you to wait ... (and since i have vacation from school, it shouldn't take long)


thanks .. :)

---------------------------------

BTW, don't you know whether there's function which returns PyRequirement and PyResult attribute ?? (ie i want to get that string "spellBlizard(caster)" from SPELL_BLIZZARD without searching through XML)
You mean like "getPyRequirement"? I'm not sure. I'll check for you if it has been exposed to python.

Yes, you can.

getPyRequirement() and getPyResult() seems to be exposed :)
 
You mean like "getPyRequirement"? I'm not sure. I'll check for you if it has been exposed to python.

Yes, you can.

getPyRequirement() and getPyResult() seems to be exposed :)

oh, great, thanks a lot!!


oops! ... code already has 530 lines / 21 kb and there's defacto nothing just few menus yet ... well but handling of last menu is going to be really crazy - i'm missing switch/case function ....
 
XML styles for this game were designed by Hyborem himself!! Almost every *.XML has another arrangement of <tags> ... grrr ...
edit: ha! problem solved... :D
edit2: crash test: I select to open all .py and .xml files and show all tags and defs .. :D ... successfully
 
btw it is were not was...
 
new version
so I updated screenshots ... :D

i won't post code, since i think that nobody would find any use for this craziness - well at least not now

@civ_king: well, especially this (forgetting 3rd person verb change) happens to me quite often ):
 
Impressive. A bit more useful than editing python by getting out of civ to find an error.

Does it reload the code once edited for both python and XML?
 
Impressive. A bit more useful than editing python by getting out of civ to find an error.

Does it reload the code once edited for both python and XML?

well ... this browser hasn't any editing functions yet - i have to make it completely able to browse first :)
but when python files are externally changed, Civilization 4 core automatically reloads them, so there shouldn't be problem with reloading code after edited in this soon-to-be-editor-now-but-only-browser, unfortunately this doesn't work with XML ...
 
There is a command to reload the Text portion of XML, so you MIGHT be able to force a reload of all XML, but it would be painful to make it also update all existing assets in the world, so would cause issues anyway.

This project is nifty, but even with ability to edit it is just nifty until it gets to the point of being able to look things up for you (ie - click on a unit or spell icon and choose from a submenu - Find Relevant Python), or step through python functions line by line while they are processed. Or even just show values for any currently active globals and/or functions in python in the browser. Those are the things you cannot do with just windowed mode and ALT-TAB to the editor of your choice, and those will be VERY nice (I assume that is where this is headed eventually, and I look forward to it. a Python debugger utility... :drool:)
 
xienwolf said:
(ie - click on a unit or spell icon and choose from a submenu - Find Relevant Python),
c++, and i'm trying to do it without c++ ... yet
but i had an idea to make it similar like UnitStatistic (codewise), after clicking on "showcode" button get selected unit - and then all spells that unit is capable of would appear in summary window and it would add proper lines in dropdown menu
xienwolf said:
or step through python functions line by line while they are processed or even just show values for any currently active globals and/or functions in python in the browser
well ... if there isn't already support for it in exe or dll, then i see no wa...
maybe altering ALL files and inject stepping code and after every line (which could be filtered) call function in debug screen
-- but initializing this would take some time, and it would triple size (backing every file up, then for each line add debug line)
and i still have to figure out how to change file/folder permissions - something says me, that there wouldn't be "$ chmod a+rw" bash command .. :D

edit: lol, i hate when i change my mind about what i want to write in the middle of sentence ... text corrected
 
since i don't want to be accused of inactivity on this project:
>> updated .. :D

(( now is missing only linewrapping, entity search, editing ... ))
 
Nice to see this updated :)

Will linewrapping be hard to do? And I think you're working on the entity search already, aren't you?
 
Nice to see this updated :)

Will linewrapping be hard to do? And I think you're working on the entity search already, aren't you?

LineWrapping is difficult due to not-monospace font...
Entity - yes, I'm ... but I'm too lazy to start that notepad++ ... :D:D
 
Top Bottom