1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

EUI: Can I buy a building after I start building?

Discussion in 'Community Patch Project' started by Stalker0, Aug 9, 2016.

  1. Funak

    Funak Deity

    Joined:
    Jul 15, 2013
    Messages:
    9,127
    Beautiful as usual. Yeah a faith-button is a lot less interesting considering you really shouldn't be faithbuying buildings you've already put plenty of hammers into.
     
  2. Meister Maggi

    Meister Maggi Warlord

    Joined:
    Jul 16, 2007
    Messages:
    187
    Right - also, certain faith-bought items cannot be produced regularly anyway. Unless I miss something, this case would only be relevant for certain beliefs that allow faith-buying otherwise buildible items - and as you said there one usually will not want to throw away the hammers.

    I also found a bit of time to continue today and the button text and the tooltip is already working correctly. Two things are still missing:
    - handling the button click;
    - taking care of the units that can be produced but not bought (for lack of an academy - I suppose there are no buildings of that kind, i.e., that can be built but not bought under some conditions, even though a buyout value exists).

    The latter is currently in progress, and I am still trying to figure out how to pass the info from the selection list items (IsDisabled()) to those in the queue (this then effects the usability of the then shaded out button, and also the tooltip).

    If anyone is an expert on that by any chance, I am open to suggestions. I will then proceed the following days when I find the time.
     
  3. Funak

    Funak Deity

    Joined:
    Jul 15, 2013
    Messages:
    9,127
    There are two reformation-beliefs, one that allows you to purchase cultural and one that allows you to purchase science buildings with faith. There is also the Spanish unique castle that can be purchased with faith. But yeah not really worth any real concern.
     
  4. Meister Maggi

    Meister Maggi Warlord

    Joined:
    Jul 16, 2007
    Messages:
    187
    Meanwhile, I managed to fix the problem of the units that can be built but not bought. The only thing missing is ensuring that clicking the button has the desired result.

    However, it seems there is something I am not doing right, as linking even only a print to the left click does not work correctly.

    If I simply include (for such gold button in the production queue - note: setting e.g. the text and the tooltip for this button works fine):

    Code:
    instance.PQGoldButton:RegisterCallback(Mouse.eLClick, print("clicked"));
    then the fire tuner returns

    CityView: clicked
    ButtonControlBase: RegisterCallback could not be called: 2 values on stack. Expected 1 parent table and 2 arguments.

    This is not too surprising as the rudimentary CiV API doc shows that RegisterCallback expects a Mousetype (like Mouse.eLClick for left click) and a function.

    If I however adapt functions used elsewhere in this context, to this situation as follows:

    Code:
    instance.PQGoldButton:RegisterCallback(Mouse.eLClick, function() print("clicked"); end);
    no print of "clicked" is shown in the fire tuner...

    What am I missing?
     
  5. Meister Maggi

    Meister Maggi Warlord

    Joined:
    Jul 16, 2007
    Messages:
    187
    I finally at least figured out what does not work though I do not know why. As it happens, associating the function call for buying into a building directly from the queue with the a right mouse button click works like a charm. At the same time, using the exact same function in association with a left click makes nothing happen, in fact, it seems the button (animation-wise) is not even clicked (using the left button).

    Has something similar ever happened to someone? (I attach a code segment, where only the last line for mouse.eLClick does not work. Does anyone have a hint o how to fix this?

    Code:
    if goldCost then
    			instance.PQGoldButton:SetDisabled( not canBuyWithGold )
    			instance.PQGoldButton:SetAlpha( canBuyWithGold and 1 or 0.5 )
    			instance.PQGoldButton:SetVoids( orderID, itemID )
    			instance.PQGoldButton:SetText( (cash>=goldCost and goldCost or "[COLOR_WARNING_TEXT]"..(goldCost-cash).."[ENDCOLOR]") .. g_currencyIcon )
    			instance.PQGoldButton:SetToolTipCallback ( PQBuyButtonToolTip )
    			instance.PQGoldButton:RegisterCallback( Mouse.eRClick, PQBuyButtonClicked )
    			instance.PQGoldButton:RegisterCallback( Mouse.eLClick, PQBuyButtonClicked )
    		end
     
  6. ExpiredReign

    ExpiredReign Deity

    Joined:
    Jan 3, 2013
    Messages:
    2,450
    Gender:
    Male
    Location:
    Tasmania
    I'm going to assume that if you reverse those two lines then the left would work and the right would not. Perhaps Lua is storing the first action with the function and doesn't recognise the next reference?
    I've not seen any code snippets in the API reference that does that, so it's just a hunch.
     
  7. Theral

    Theral Chieftain

    Joined:
    Aug 23, 2016
    Messages:
    7
    I didn't even know I could still invest into a building that's already in the queue, and now that I first learn about it I also learn that soon we will be having a fancy new button for it! That's awesome, thanks!
     
  8. Meister Maggi

    Meister Maggi Warlord

    Joined:
    Jul 16, 2007
    Messages:
    187
    Thanks for the idea, unfortunately, it does not work. I had been using the association to the left click only and nothing ever worked (I tried your hint anyway quickly, but to no avail). In my opinion, it should actually also be possible to call the same function with left and right click (though we hardly ever see that as it does not make too much sense).

    I am inclined to believe now that something in the queue functionalities "blocks" the left click from working on this button, but this is also just a hunch...
     
  9. Meister Maggi

    Meister Maggi Warlord

    Joined:
    Jul 16, 2007
    Messages:
    187
    Well, such block seems not to exist from the queues funcionality, at least not in an obvious way.

    I may do further inquiries - does anybody know if there is a way via live tuner to monitor what happens if a button is pressed?

    Anyway, I may upload it included in my improved city view mod as new version for testing (or even help with this bug) - I can easily extract then the version for Vox Populi (EUI) alone. What do you think?
     
  10. Meister Maggi

    Meister Maggi Warlord

    Joined:
    Jul 16, 2007
    Messages:
    187
    I just updated the EUI version of my mod for the improved city view now including the right-clickable buy button in the queue.

    http://steamcommunity.com/sharedfiles/filedetails/?id=737188253

    Please check it out and let me know if there are any bugs (besides the odd behavior on left-click) or if you even have a idea on how to fix this.
     
  11. Enrico Swagolo

    Enrico Swagolo Deity

    Joined:
    Jun 10, 2013
    Messages:
    2,380
    Looks really good, especially the part on the right with specialists of the same kind being merged. Subscribed and thanks.
     
  12. Enrico Swagolo

    Enrico Swagolo Deity

    Joined:
    Jun 10, 2013
    Messages:
    2,380
    Checked it out, alas the mod is not very good.

    Flaws:

    Changing queue during turn end is impossible. Even after new one starts, you need to leave the city queue. It's pretty annoying.

    The entire button is harder to use than just unticking the building and putting it back in. Sometimes works, sometimes doesn't.

    Changing queue order is way worse than VP EUI, can't drag, must click a lot of times if I make a long queue.

    The flaws outweigh the positives as it stands. Once the majority of the flaws is fixed though (especially the first one), it would be an upgrade.
     
  13. Meister Maggi

    Meister Maggi Warlord

    Joined:
    Jul 16, 2007
    Messages:
    187
    Thanks for the feedback. Could you be more specific though as to what does not work under which combination of mods and maybe even provide a save so that I can have a look?

    I just tested it with the published version, and at least within the cityview of one city, the right click on the buy button works for me 100% as well as moving around items in the queue (of length 15-20). But apparently I miss something, because I was not aware that I can change the queue of a city "during the end of the turn" - is this a feature of EUI I have not yet grasped? Also, which city queue - if I interpret this correctly - it seems some other files (outside the cityview) should be affected as well?
     
  14. Enrico Swagolo

    Enrico Swagolo Deity

    Joined:
    Jun 10, 2013
    Messages:
    2,380
    EUI version, regular, removed all the necessary, recommended files.

    I don't mean just clicking the arrows, I mean dragging items lower/higher which is faster and requires way less click inputs.

    Yes, in EUI you can change queues as much as you want - sometimes it lags, though, around 300-400 turns in the game, but before that it is pretty awesome.

    I mean city queue, which is the building order. Left lower part of the screen, with all the thingamajigs.
     
  15. Meister Maggi

    Meister Maggi Warlord

    Joined:
    Jul 16, 2007
    Messages:
    187
    So this means the building order queue in the lower left corner of the city view and dragging around items.

    But this works perfectly fine for me. I must admit though I am using a newly started game in the information age, which may not have the problems you describe which rather seem to be matters of performance I could not test yet.

    - Do you have a save (for which version of VP)?
    - Does anybody else observe the same problems?
     
  16. Meister Maggi

    Meister Maggi Warlord

    Joined:
    Jul 16, 2007
    Messages:
    187
    Also, regarding performance:
    - Does (by any chance) the left click work - if not then I can also remove the link to the function (to make the code lighter in that regard)?
     
  17. Meister Maggi

    Meister Maggi Warlord

    Joined:
    Jul 16, 2007
    Messages:
    187
    I just uploaded a new version fixing a bug on reset of shown info - can you please check if this fixes the problems you observed?
     
  18. Enrico Swagolo

    Enrico Swagolo Deity

    Joined:
    Jun 10, 2013
    Messages:
    2,380
    Sorry, I completely forgot about the thread and didn't have much time lately.

    Of course, I will check it all out and report (+send save) if I find problems once I have an opportunity to play.
     
  19. Enrico Swagolo

    Enrico Swagolo Deity

    Joined:
    Jun 10, 2013
    Messages:
    2,380
    I've just realised I was using the wrong mod version (the non-EUI one)! Now that I've installed the right one, everything is fine.

    As it stands, it seems to be an upgrade in every way. Job well done, awesome mod.
     
  20. Meister Maggi

    Meister Maggi Warlord

    Joined:
    Jul 16, 2007
    Messages:
    187
    Thanks - that sometimes happens with all the different versions.

    The EUI-one is still under improvement and following a very helpful discussion with whoward69

    http://forums.civfanatics.com/showthread.php?p=14417226&posted=1#post14417226

    I finally managed to make the button left-clickable - a further upgrade will follow, which eventually will also make it into the main VP mod (if I got Gazebos message correctly).
     

Share This Page