Announcement

Collapse
No announcement yet.

Q: How to make popup message boxes

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

  • Q: How to make popup message boxes

    I was wondering how to make a popup message box in Civ IV. The reason I want to know is that I plan to use the message boxes to make sure code I call is really being called before I write the real code.

    I tried writing to a log file but it didn't seem to work (see below)

    Code:
    'Report an Event to Events.log '
    		message = "BeginTurn event called"
    		CyInterface().addImmediateMessage(message,"")
    		CvUtil.pyPrint(message)
    		return 0
    I couldn't find the 'Events.log' in the logs folder even though I enabled event logging in the ini file.

    ; Enable the logging system
    LoggingEnabled = 1

    ; Overwrite old network and message logs
    OverwriteLogs = 1

    ; Enable rand event logging
    RandLog = 1

    ; Enable message logging
    MessageLog = 1

  • #2
    Code:
    	popup = PyPopup.PyPopup()
    	popup.setBodyString( 'Hello World' )
    	popup.launch()

    Comment


    • #3
      Thanks.

      Unfortunately that only confirms that my code isn't being called because no "hello world" ever came up.

      I put the following into CVEventManager.py. No dice.

      Code:
      def onBeginPlayerTurn(self, argsList):
      		'Called at the beginning of a players turn'
      		iGameTurn, iPlayer = argsList
      		popup = PyPopup.PyPopup()
      		popup.setBodyString( 'Hello World' )
      		popup.launch()
      Actually, I first put it into my own python file and had a CVCustomEventManager include it but that all seems ambitious now. I'd just like to get the stupid thing to work in the regular EventManager first.

      Comment


      • #4
        I had some simple code that worked with popups under 1.0 (not tested under 1.09). Look at:




        CvAUEvents pops up a reminder every 25 turns for people making During-Action-Reports at regular intervals. CvEventInterface just had a two lines changed to make the new event handler class get called.

        These go in CustomAssets.

        Kidinnu

        Comment


        • #5
          Originally posted by Kidinnu
          I had some simple code that worked with popups under 1.0 (not tested under 1.09). Look at:




          CvAUEvents pops up a reminder every 25 turns for people making During-Action-Reports at regular intervals. CvEventInterface just had a two lines changed to make the new event handler class get called.

          These go in CustomAssets.

          Kidinnu
          I copied yoru files directly and put them in My Documents\My Games\Civ4\CustomAssets\python and My Documents\My Games\Civ4\CustomAssets\python\entrypoints but I still don't see any popups (I change the modulous to % 2 instead of % 25 so I wouldn't have to wait 25 turns to test it but other then that it was a direct copy). Do I have to clear out a cache or something? I've heard some people mention that on other threads.

          Roger Bacon

          Comment


          • #6
            I'm starting to hate Python.

            I can't get the following code to create a popup no matter WHERE I put it.

            Code:
            def onBeginPlayerTurn(self, argsList):
            		'Called at the beginning of a players turn'
            		popup = PyPopup.PyPopup()
            		popup.setBodyString( 'Hello World' )
            		popup.launch()
            I put it in my own file which is included in CVCustomEventManager.py. When that didn't work I included the popup part directly into the CVEventManager.py and that didn't work. I even put it on the CVEventManager.py in the main Civ4\Assets\Python directory (the ones you aren't supposed to mess with) just on the off chance that it wasn't looking in my My Documents\My Games\Civ4\CustomAssets\python path. NONE of those places produced a single popup or a single error message. The program just keep happily going along ignoring all of my code. Even a crash would be preferable to this.

            Roger Bacon

            Edit

            After much work I've finally gotten it to work.
            I needed to do self.NameOfCustomClass.FunctionName instead of NameOfCustomClass.FunctionName. I still am not sure why the first one didn't work because I copied the realFort code and it worked for him.
            Last edited by rogerbacon; December 3, 2005, 03:57.

            Comment

            Working...
            X