UI - Notification Options

The lua file:

Code:
include("IconSupport")

-- Data structure about the notification, passed in the LuaEvent below
local Emigration = {
  label = "TXT_KEY_EMIGRATION_NOTIFICATION_LABEL", 
  key   = "EMIGRATION_NOTIFICATION", 
  item  = "EmigrationNotification",
  show  = true, 
  ui    = true, 
}

-- This is executed when the notification is issued, build the entry for the list and hook up any events
function OnEmigrationNotification(cbData)
  local instance = {}
  ContextPtr:BuildInstanceForControl("EmigrationItem", instance, cbData.parent)
  cbData.instance = instance
  
end
Emigration.callback = OnEmigrationNotification

-- We have to get a bit defensive here as Firaxis keep changing the order that events fire.
-- This approach means we don't care if this code executes before or after the "UI - Notifications Options" code
function OnEmigrationNotificationIdRequest()
  if (Emigration.id ~= nil) then
    LuaEvents.EmigrationNotificationId(Emigration.id)
  end
end
LuaEvents.EmigrationNotificationIdRequest.Add(OnEmigrationNotificationIdRequest)

function Register()
  LuaEvents.CustomNotificationAddin(Emigration) -- Name of the data structure at the top of the file
  OnEmigrationNotificationIdRequest()
end

Register()


function OnEmigrationEvent(pFromPlayer, pToPlayer, pFromCity)
	local strToName = Locale.ConvertTextKey(pToPlayer:GetNameKey());
	local strFromCity = Locale.ConvertTextKey(pFromCity:GetNameKey());

	local heading = Locale.ConvertTextKey("TXT_KEY_EMIGRATION_EVENT_HEADING", strToName);
	local text = Locale.ConvertTextKey("TXT_KEY_EMIGRATION_EVENT_TEXT", strFromCity, strToName);

	pFromPlayer:AddNotification(g_EmigrationNotificationType, text, heading, -1, -1, 0);

end
LuaEvents.EmigrationEvent.Add( OnEmigrationEvent );

There's some fumbling around in there, and I got in the habit of putting the listener for the event that is supposed to cause the notification in that lua file, but that's the complete text of the lua file.

Everything about the notification is working exactly as I expect except the icon.
 
Code:
	<Instance Name="EmigrationItem" >
		<Container Anchor="R,C" Size="80,80" Offset="0,0"  Hidden="0" ID="EmigrationContainer" ConsumeMouseButton="1" >
			<SlideAnim Anchor="L,T" Style="NotificationSlide" ID="NotificationSlide" >
				<AlphaAnim Style="NewFinger" />
				<Button Anchor="R,C" Size="80,80" Offset="0,0" Texture="assets\UI\Art\Notification\NotificationFrameBase.dds" ID="EmigrationButton"  Hidden="0" >
					<ShowOnMouseOver>
						<Image Anchor="C,C" Offset="0,0" Size="80,80" Texture="assets\UI\Art\Notification\NotificationFrameBase.dds" />
						<AlphaAnim  Anchor="C,C"  AnchorSide="O.O"  Offset="0,0" Size="80,80" Texture="assets\UI\Art\Notification\NotificationCityGrowthRed.dds"  Pause="0" Cycle="Bounce" Speed="1" AlphaStart="1" AlphaEnd="0" Hidden="0"/>
					</ShowOnMouseOver>
					<Image Anchor="C,C" Offset="0,0" Size="80,80" Texture="assets\UI\Art\Notification\NotificationCityGrowthRed.dds" />
					<AlphaAnim Anchor="C,C" Offset="0,0" Size="80.80"  TextureOffset="0.0" Texture="assets\UI\Art\Notification\NotificationCityGrowthRedGlow.dds"  Pause="0" Cycle="Bounce" Speed="1" AlphaStart="0" AlphaEnd="1"/>
				</Button>
			</SlideAnim>
		</Container>
	</Instance>
This is the code that I have as the Emigration notification. I've managed to get it to work properly with this modcomp. It's slightly different than yours, in terms of what "Texture" is defined as.

Also, I noticed your lua doesn't have a click event. Mine works like this:

Code:
function OnLookAt(pPlot)
  if (pPlot ~= nil) then
    UI.LookAt(pPlot)
  end
end

function OnEmigrationNotification(cbData)
  local instance = {}
  ContextPtr:BuildInstanceForControl("EmigrationItem", instance, cbData.parent)
  cbData.instance = instance
  pPlot = Map.GetPlot(cbData.iExtra1, cbData.iExtra2)
  -- MUST use a closure (anonymous function) as the click event
  instance.EmigrationButton:RegisterCallback(Mouse.eLClick, function() OnLookAt(pPlot) end) 
end
Emigration.callback = OnEmigrationNotification

I don't recognize the OnEmigrationEvent function, but when I call the notification I do this:
Code:
fromPlayer:AddNotification(g_EmigrationNotificationType, txt, smr, fromCity:GetX(), fromCity:GetY(), fromCity:GetX(), fromCity:GetY())

I hope that helps.
 
Would you mind posting your complete lua function, or PMing it to me/zipping it up/w.e. is easiest?
 
Adds a dialog to permit specific notifications to be enabled/disabled


Hmm, how do I make that dialog appear in the game? After downloading, installing (putting the file in the mods folder), and activating (via the Mods menu) the "UI - Notification Options (GK) (v 4)" mod, I don't see any button anywhere in the game interface to make that dialog appear. :confused:
 
It's on the "Diplo Corner" menu (scroll icon top right), should be under the standard Notification Log option
 
How do you reference an image in a grid based file such as units, buildings?
 
It's on the "Diplo Corner" menu (scroll icon top right), should be under the standard Notification Log option

Yeah, I figured that it would be there because that was where Alpaca's old Improved Notifications mod had them, but there was no such button in that menu.

I then disabled all other mods and cleared out my cache ("Documents\My Games\Sid Meier's Civilization 5\cache") and tried again.

But now when I start a game with that mod and NO OTHER MODS, I get the following when the game starts up:

Spoiler :


Spoiler :


Basically, I get an empty Notification Options dialog box, with nothing in it. To make things worse, I can't make the box go away. If I click on the "Close" button at the bottom right, doing so depresses the button, but does NOT make the dialog box go away. Pressing the escape (ESC) key doesn't work either. So I get trapped with that dialog box that won't go away. :(

Any ideas how to fix this? :confused: Thanks.
 

Attachments

  • Notification Options 1.jpg
    Notification Options 1.jpg
    59.9 KB · Views: 719
  • Notification Options 2.jpg
    Notification Options 2.jpg
    61.6 KB · Views: 704
What's in Lua.log?

In case it matters, my OS is Win7. Here is the relevant section, as well as a few surrounding lines, of the log, with my username edited out and replaced with %USERNAME% for privacy:

Code:
[37661.433] ChoosePantheonPopup: -314
[37661.433] ChoosePantheonPopup: 963
[37661.433] ChoosePantheonPopup: 649
[37663.352] NotificationOptions: This is the 'UI - Notifications Options' mod script.
[37663.368] Runtime Error: [string "C:\Users\%USERNAME%\Documents\My Games\Sid Mei..."]:133: table index is nil
stack traceback:
	[string "C:\Users\%USERNAME%\Documents\My Games\Sid Mei..."]:133: in main chunk
	[C]: ?
[37663.368] Runtime Error: Error loading C:\Users\%USERNAME%\Documents\My Games\Sid Meier's Civilization 5\MODS\UI - Notification Options (GK) (v 4)\UI/NotificationOptions.lua.
[37664.428] Demographics: Dequeuing demographics
[37664.428] Demographics: Dequeuing demographics
[37677.533] TechTree: REFRESHING TECH DISPLAY
 
Obvious questions first

1) G&K or Vanilla?
2) PC or Mac
3) What's the build number (you can find this at the very bottom of the Main Menu)

And can you confirm that line 133 in that file reads as

Code:
g_Notifications[NotificationTypes.NOTIFICATION_REQUEST_RESOURCE] = {item="BonusResource", key="NOTIFICATION_REQUEST_RESOURCE", show=true, ui=true}
 
Obvious questions first

1) G&K or Vanilla?
2) PC or Mac
3) What's the build number (you can find this at the very bottom of the Main Menu)

And can you confirm that line 133 in that file reads as

Code:
g_Notifications[NotificationTypes.NOTIFICATION_REQUEST_RESOURCE] = {item="BonusResource", key="NOTIFICATION_REQUEST_RESOURCE", show=true, ui=true}

1) G&K
2) PC, and for that matter, Win7, as I mentioned in my earlier post
3) 1.0.1.674

Line 133 of NotificationOptions.lua indeed exactly reads that.

I tried commenting just that line out, and, OMG, it looks like now the mod works! :D I now get a non-empty dialog box which actually goes away when I click the "Close" button! :cool: Thanks so much for your help! :goodjob:

At least I think it works... I haven't really had a chance to try it out much yet, but I did have one question: in contrast to the screenshot in your original post which only has one column of checkmarks, the dialog box I'm seeing has two columns of checkmarks:

Spoiler :


Is this what I'm supposed to be seeing? (That is, did you change the mod from that original version with only one column of checkmarks?) And if so, what's the difference between the two columns?
 

Attachments

  • Notification Options 3.jpg
    Notification Options 3.jpg
    108.5 KB · Views: 694
Are there supposed to be two columns of checkmarks?

Yes, IIRC the left hand one is for the User, the right for the Current Game. Uncheck the left hand one and you will never see those alerts again for any games player, uncheck the right hand one and you will not see any more of those alerts for the current game
 
And can you confirm that line 133 in that file reads as

Code:
g_Notifications[NotificationTypes.NOTIFICATION_REQUEST_RESOURCE] = {item="BonusResource", key="NOTIFICATION_REQUEST_RESOURCE", show=true, ui=true}

Line 133 of NotificationOptions.lua indeed exactly reads that.

I tried commenting just that line out, and, OMG, it looks like now the mod works! :D I now get a non-empty dialog box which actually goes away when I click the "Close" button! :cool: Thanks so much for your help! :goodjob:

Just one more note on this, in case anyone is interested: I looked around the code some more and found out that rather than commenting out line 133, an alternative way to fix the problem I was having was to change the word "REQUEST" to "DEMAND", so that the line reads:

Code:
g_Notifications[NotificationTypes.NOTIFICATION_DEMAND_RESOURCE] = {item="BonusResource", key="NOTIFICATION_DEMAND_RESOURCE", show=true, ui=true}
 
On a different subject, just thought I'd report two issues, with an attached savegame (which, by the way, requires the Info Addict mod) to reproduce.

First, and this is just a minor cosmetic-only issue (display-only issue) with no gameplay effect, is that there are two apostrophes in the "Spy Can''t Steal Tech" choice in the dialog box when there should only be one, as seen in this screenshot:

Spoiler :


Second, and this is the more important thing, there is a issue that was also in alpaca's Improved Notifications mod from a couple years ago, so I think it's something left over from that which was never fixed? Basically, when a city has tiles extending beyond the 3-tile working range of the city (that is, it only affects tiles owned by a city that are at least 4 tiles distant from the city, meaning you will mostly see this issue if you play culturally and grow tall rather than REX/ICS and grow wide), whenever you load a savegame, the notifications for ALL such 4+ distance tiles will reappear as if the growth took place in the turn you loaded the game, hitting you with notifications and flooding your notifications log. See these screenshots:

Spoiler :


Spoiler :


Obviously, the city didn't claim all those tiles in this single turn. The problem only occurs on the turn that you load the game; if you play to the next turn, you won't get hit with the notifications again, though your notifications log will still be filled with the notifications. The problem is not restricted to this one savegame, though, in the sense that if you continue playing on to the next turn, and then save the game again, this time to a different savefile, and then load that new 2nd savefile, that 2nd savefile will be afflicted with the same problem.
 

Attachments

  • Maria Theresa_0122.Civ5Save
    800.9 KB · Views: 157
  • DoubleApostrophe.jpg
    DoubleApostrophe.jpg
    150.2 KB · Views: 719
  • TileNotifications1.jpg
    TileNotifications1.jpg
    224 KB · Views: 702
  • TileNotifications2.jpg
    TileNotifications2.jpg
    187.3 KB · Views: 676
whoward69, so do I understand correctly that I install and use your mod and then add the additional codes (as shown in some of the posts) to my mod? To replace a notification, the bombard example is the one to follow correct? Also, I've never encountered making changes to the .modinfo file, can you give me a little more information on that? Thanks.
 
This mod just vanishes all options for me (diplomacy, world congress, victory progress, etc)
 
Hello.
Help here?
Code:
[244975.078] NotificationPanel: This is the modded NotificationPanel from 'UI - Notification Options'
[244975.078] Runtime Error: D:\My Documents\My Games\Sid Meier's Civilization 5\MODS\Pickandmix UI - Notification Options (v 13)\UI\InGame\WorldView\NotificationPanel.lua:62: attempt to index field 'TechButton' (a nil value)
[244975.078] Runtime Error: Error loading D:\My Documents\My Games\Sid Meier's Civilization 5\MODS\Pickandmix UI - Notification Options (v 13)\UI\InGame\WorldView\NotificationPanel.lua.

All notifications are turned off by default in game and despite error i cant even find where is notification options suppose to be.
--edit
i figured out, this mod is not compatible with Vox Populi eui. They edit same files and cancel each other.
Entire top panel disappears when this mod is activated
 

Attachments

  • Sid Meier's Civilization V Screenshot 2022.10.03 - 23.34.34.04.jpg
    Sid Meier's Civilization V Screenshot 2022.10.03 - 23.34.34.04.jpg
    403.7 KB · Views: 21
Last edited:
Top Bottom