Announcement

Collapse
No announcement yet.

Centering "press <enter> to end turn..." on screen

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Centering "press <enter> to end turn..." on screen

    It happens quite often that I miss the "press to end turn..." text. I've therefore gone into the python scripts to make sure the text is centered on the screen instead of at bottom.

    Thought you might be interested in the simple mod, go into Assets\Python\Screens\CvMainInterface.py on line 730.

    original:
    screen.showEndTurn( "EndTurnText" )
    if ( CyInterface().getShowInterface() == InterfaceVisibility.INTERFACE_SHOW or CyInterface().isCityScreenUp() ):
    screen.moveItem( "EndTurnText", 0, yResolution - 194, -0.1 )
    else:
    screen.moveItem( "EndTurnText", 0, yResolution - 86, -0.1 )
    modified:
    screen.showEndTurn( "EndTurnText" )
    if ( CyInterface().getShowInterface() == InterfaceVisibility.INTERFACE_SHOW and CyInterface().isCityScreenUp() == 0 ):
    screen.moveItem( "EndTurnText", 0, yResolution / 2 - 100, -0.1 ) # ao center on screen
    elif ( CyInterface().isCityScreenUp() ):
    screen.moveItem( "EndTurnText", 0, yResolution - 194, -0.1 )
    else:
    screen.moveItem( "EndTurnText", 0, yResolution - 86, -0.1 )

  • #2
    Shouldn't it be " elseif ( CyInterface().isCityScreenUp() ):" instead of " elif ( CyInterface().isCityScreenUp() ):"

    Comment


    • #3
      Originally posted by JDexter
      Shouldn't it be " elseif ( CyInterface().isCityScreenUp() ):" instead of " elif ( CyInterface().isCityScreenUp() ):"
      Not in python

      Comment


      • #4
        I've replaced the text as recommended in CvMainInterface, but I get an error dialog when loading Civ4 "failed to load Python module CvEventInterface."

        I've replaced the text using both a cut and paste from your example, exactly replacing the original text, and I've keyed it in manually to match your new text. I'm assuming there are no typos in my work (I've tried 3 times, same result).

        I've programmed C++ and I know that whitespaces and indenting has no effect on the code. Is this the same with Python? This is my first foray into Python, and I figured a quick and dirty text replacement to center the text would be a great way to jump in.

        Any advice? Is there a quirk to editing python text files (using NotePad) that disrupts my work?

        Oh, and of course I've copied my original pythons to a safe place - so at least I figured that out

        Hope you can help.
        XP SP2; 1280MB w/3200MB virtual memory
        AMD Athlon 1700+; 500W power, 2HD's
        Radeon 9600pro 256MB (Dec 2005 Catalyst)
        SoundBlaster X-Fi (8.8.05 driver)

        Comment


        • #5
          I've programmed C++ and I know that whitespaces and indenting has no effect on the code. Is this the same with Python?
          No. In Python, indentation is significant. Where in C++ you would enclose a block in braces, in Python, you indent it.

          In the code above, the screeen.moveItem statements should be indented with respect to the if/elif/else lines.

          Essentially, whenever you see a :, the following line needs to be indented.

          One last piece of advice: do not mix tabs and spaces.

          Comment


          • #6
            Originally posted by Fruny
            One last piece of advice: do not mix tabs and spaces.
            Wise advice not heeded at one's own risk.

            I use Python's IDLE to edit files (shame on me) and tabs are off by default, meaning you have to turn them on every time you do anything. Forget and bad things can ensue... I should really change software...

            Comment


            • #7
              When I don't really need to work interactively, I use SPE. I fall back on IDLE for quick edits or interactive work.

              SPE's interpreter window has ... issues, but it's otherwise a pretty good editor.

              Comment


              • #8
                I've heard there's a plugin that allows you to use Visual Studio and have colored syntax... do you know if that's true? The only reason I don't use it is because I want my text to not be all white...

                Comment


                • #9
                  There's ActiveState's Visual Python. I don't know how good it is, nor how good its syntax highlighting is (the screenshots are rather inconlusive). There's a trial version, if you're interested.

                  Comment


                  • #10
                    I am still unable to get this to work... Is using Notepad to edit Py files a problem?

                    Here's the text, showing my indentations, using NO TABS, spaces only:


                    if ( bShow ):
                    screen.showEndTurn( "EndTurnText" )
                    if ( CyInterface().getShowInterface() == InterfaceVisibility.INTERFACE_SHOW and CyInterface().isCityScreenUp() == 0 ):
                    screen.moveItem( "EndTurnText", 0, yResolution / 2 - 100, -0.1 ) # ao center on screen
                    elif ( CyInterface().isCityScreenUp() ):
                    screen.moveItem( "EndTurnText", 0, yResolution - 194, -0.1 )
                    else:
                    screen.moveItem( "EndTurnText", 0, yResolution - 86, -0.1 )
                    else:
                    screen.hideEndTurn( "EndTurnText" )


                    ... and CvMainInterface fails to load on startup. Can anyone see what is wrong with this text?

                    Thanks, I'd like to post this to my mod... and it is my first attempt at tweaking Python.

                    Spocko

                    EDIT: well, never mind on the indents - pasting the text into this forum window eats all the leading spaces. So, could one of you kind souls edit my text to show how it should appear? I truly think I have the correct spacing ... or maybe attach a copy of the Py file for my downloading? Thanks everyone!
                    XP SP2; 1280MB w/3200MB virtual memory
                    AMD Athlon 1700+; 500W power, 2HD's
                    Radeon 9600pro 256MB (Dec 2005 Catalyst)
                    SoundBlaster X-Fi (8.8.05 driver)

                    Comment


                    • #11
                      I had the exact same problem, so went ahead and did it.

                      Here's the code in a text file. Just paste it in instead of the original code in a text editor (I use Editpad). It works on my install.

                      EDIT: Look below for the updated file.
                      Last edited by RO; January 5, 2006, 13:30.
                      Enjoy,

                      Robert

                      Comment


                      • #12
                        Thank you!

                        Excellent!

                        Your text file worked perfectly!

                        Thank you for taking the time to post the text file.

                        Cheers,
                        Spocko
                        XP SP2; 1280MB w/3200MB virtual memory
                        AMD Athlon 1700+; 500W power, 2HD's
                        Radeon 9600pro 256MB (Dec 2005 Catalyst)
                        SoundBlaster X-Fi (8.8.05 driver)

                        Comment


                        • #13
                          Thanks.
                          However, I just found out this this centering does not work when the minized interface is on (Ctrl+i). I'll try to figure out why that's so, but it isn't immediately obvious.
                          Enjoy,

                          Robert

                          Comment


                          • #14
                            OK, found it (I think).

                            Get the edited code file here
                            Attached Files
                            Enjoy,

                            Robert

                            Comment


                            • #15
                              Got it. Thanks again!

                              Spocko
                              XP SP2; 1280MB w/3200MB virtual memory
                              AMD Athlon 1700+; 500W power, 2HD's
                              Radeon 9600pro 256MB (Dec 2005 Catalyst)
                              SoundBlaster X-Fi (8.8.05 driver)

                              Comment

                              Working...
                              X