center of the screen on the city when an event occurs

Discussion in 'Civ4Col - We The People' started by Mr. ZorG, Sep 29, 2020.

  1. Mr. ZorG

    Mr. ZorG Prince

    Joined:
    Feb 13, 2020
    Messages:
    334
    Gender:
    Male
    Location:
    Russia, Vladimir
    on Ray's advice, so that the request is not lost, I make it out with a new theme.

    there are situations in the game when there is not enough resource for the final construction of a building. and when this resource appears in the city in the required quantity, a message appears stating that the building can be built. So here's the question: is it possible to make the screen move to the designated city?

    the attached screenshot shows that one building from the list can be built in the city of Fort Ross. but at the same time Novo Arkhangelsk is displayed on the map. I don't remember which building is more needed in the city. but if I saw the city on the map, it would be easier to choose.

    I can test the change and give feedback any day
     

    Attached Files:

  2. Nightinggale

    Nightinggale Deity

    Joined:
    Feb 2, 2009
    Messages:
    4,934
    I like the idea. The way to move the camera is the way I just committed for the native advisor:
    PHP:
    CyCamera().JustLookAtPlot(CyPlot instance)
    CyCamera().JustLookAtPlot(gc.getMap().plotByIndex(iPlotIndex)
    Two problems:
    This is something we can only do in python. Since we can make the DLL call python, it is doable to do this in the DLL. It just means extra work.

    The second problem is the most severe. When should the code be called to move to the colony? There is a function, which builds the popup window and then sends it to the exe to be displayed. We can call it there. However the exe doesn't display right away. It adds the window to a queue. This means we can make A, make B, make C (A, B, C being events at different colonies) and then display A, display B, display C. Since the jump will occur when making, it will already have moved to C by the time the A window shows up. In other words it will not really work if we do it this way.

    We should jump when the message is displayed, but that happens inside the exe, meaning we can't add extra code to that event. This means the action itself is easy to add, but we don't have anywhere to put it unless we get really creative.

    I can think of two solutions
    1. keep the queue in the DLL and only send one popup request at a time. This isn't a 5 minute job.
    2. stop calling the exe. Instead make out own custom popup in python. This is even more work, but it will solve a whole lot of issues (size on high resolution to name the most obvious)
    As much as I would like this feature, the solutions will require too much development time to start on them right away. There are other features, which are more urgent.
     
  3. raystuttgart

    raystuttgart Civ4Col Modder Supporter

    Joined:
    Jan 24, 2011
    Messages:
    7,516
    Gender:
    Male
    Location:
    Stuttgart, Germany
    Why not simply add the normal "Examine Settlement" as Selection Option to the pop-up list? :dunno:
    (Like it is available in most other pop-up lists for Cities as well.)

    Thus it should be relatively easy to do (for an experienced modder) and it would also be consistent with most other pop-ups for Cities.
    (Lots of examples for that already exist, e.g. the normal pop-up when a City has finished its construction.)

    ----------

    There would be no need to design and implement a new solution concept.
    (Thus not needing to invest massive efforts.)

    Keep it simple. :thumbsup:
    Otherwise modders will drown in effort.
     
    Last edited: Sep 30, 2020
    Mr. ZorG likes this.
  4. raystuttgart

    raystuttgart Civ4Col Modder Supporter

    Joined:
    Jan 24, 2011
    Messages:
    7,516
    Gender:
    Male
    Location:
    Stuttgart, Germany
    If I undestand @Mr. ZorG correctly he is talking specifically about this popup here.

    The solution concept I would suggest is to add "Examine Settlement" as Selection Option to the popup list.
    (Everything else most likely gets way more difficult and much more effort.)

    Some small help to get started for new modders:

    The name of the popup (which you can use for searching):
    BUTTONPOPUP_CHOOSE_YIELD_BUILD

    The DLL function that builds the popup in DLL (here you most likely need to add code):
    bool CvDLLButtonPopup::launchChooseYieldBuildPopup(CvPopup* pPopup, CvPopupInfo &info)

    The DLL function that calls the launch function for the popup in DLL (less important - just so you know):
    void CvCity::checkCompletedBuilds(YieldTypes eYield, int iChange)

    The DLL function that reacts on the popup input in DLL (here you most likely need to add code):
    void CvDLLButtonPopup::OnOkClicked(CvPopup* pPopup, PopupReturn *pPopupReturn, CvPopupInfo &info)

    This case needs to be adjusted to also react on "Examine Settlement":
    case BUTTONPOPUP_CHOOSE_YIELD_BUILD:

    You can copy (and adapt) code from this case in the same function:
    case BUTTONPOPUP_CHOOSEPRODUCTION

    -----

    For comparison check this popup (normal construction popup):
    BUTTONPOPUP_CHOOSEPRODUCTION

    The function that builds the popup in DLL (here you can probably copy code):
    bool CvDLLButtonPopup::launchProductionPopup(CvPopup* pPopup, CvPopupInfo &info)

    look for e.g.:
    gDLL->getPythonIFace()->callFunction(PYGameModule, "showExamineCityButton", argsList2.makeFunctionArgs(), &lResult);

    -----

    Comment:


    This requires some basic programming knowledge and also some basic Civ4Col modding knowledge.
    I would estimate about 1h to 2h of effort to fully understand, implement and test this.

    It may take some time to understand.
    It is still doable though if you take your time, because you have really nice example code.

    What makes this a bit more complicated is to understand how DLL and Python interact.
    The functions that construct these popups are also relatively long to read.

    It is thus not necessary a task for a complete beginner.
    (Somebody new to both programming and Civ4Col modding.)

    Summary:

    Experienced Civ4BTS / Civ4Col modder that knows programming: Piece of cake (still taking about 1h of effort though - unless I have missed something doing the code check)
    Modder with basic Civ4BTS / Civ4Col programming experience: Doable without real problems because good example exists (taking a bit longer though to understand the example)
    Absolute beginner without Civ4BTS / Civ4Col programming experience: Maybe a bit too challenging (because the example might then be too difficult to understand)

    -----

    It would be really nice to see a new modder (with a bit of programming experience) give this a try. :)
    This is really a good example to get some Civ4Col programming experience.

    Good luck with modding this. :thumbsup:
    And if you have questions simply ask experienced modders for help.
     
    Last edited: Sep 30, 2020
  5. Oberon4278

    Oberon4278 Chieftain

    Joined:
    Dec 8, 2005
    Messages:
    28
    Does this still need to be added?
     
  6. Mr. ZorG

    Mr. ZorG Prince

    Joined:
    Feb 13, 2020
    Messages:
    334
    Gender:
    Male
    Location:
    Russia, Vladimir

Share This Page