Fully Modifiable Custom Notifications

Family comes first, and video games far behind. Hope he recovers quickly.
 
Back to the basics here, just trying to get some standard stuff going. I successfully got this to display on the console:

NotificationPanel: Loaded Context: BC - Events

Now I've got some bug at the site the notification is called, if you can spot what I'm doing wrong. It's executing alright without errors and displays the debug text after the notification call. The notification isn't showing up however, so I must have not set up the XML file right...

I've attached the project folder here if that helps.

Code:
include( "CustomNotification" )

...inside a function...

-- Create partisans
logger:debug("Partisans");
lostPlayer:InitUnit( getBestUnitType(lostPlayer), capitalCity:GetX(), capitalCity:GetY() );
if lostCityPlot:IsRevealed(Game.GetActiveTeam()) then
  CustomNotification(
    "Refugees",
    "Refugees fled "..lostCityName,
    "Refugees from "..lostCityName.." fled to the [ICON_CAPITAL] Capital!",
    capitalCity:Plot(),
    0,
    "Red",
    0
  )
  logger:debug(" Displayed Notification");      
  --Events.GameplayAlertMessage("Refugees from "..lostCityName.." fled to the [ICON_CAPITAL] Capital!");
end

Spoiler :
Code:
<?xml version="1.0" encoding="utf-8"?>
<Context Name="BC - Events">
  <Instance Name="RefugeesItem" >
    <Container Anchor="R,C" Size="80,80" Offset="0,0"  Hidden="0" ID="RefugeesContainer" 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="RefugeesButton"  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\NotificationFrameGlow2.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\NotificationRefugees.dds" />
          <AlphaAnim Anchor="C,C" Offset="0,0" Size="80.80"  TextureOffset="0.0" Texture="assets\UI\Art\Notification\NotificationRefugeesGlow.dds"  Pause="0" Cycle="Bounce" Speed="1" AlphaStart="0" AlphaEnd="1"/>
          <Label Anchor="C,C" Offset="0,0" String="" Font="TwCenMT20" ColorSet="Beige_Black_Alpha" FontStyle="Shadow" ID="RefugeesCount" />
        </Button>
      </SlideAnim>
    </Container>
  </Instance>
  <Instance Name="CSCaptureItem" >
    <Container Anchor="R,C" Size="80,80" Offset="0,0"  Hidden="0" ID="CSCaptureContainer" 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="CSCaptureButton"  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\NotificationFrameGlow2.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\NotificationCSCapture.dds" />
          <AlphaAnim Anchor="C,C" Offset="0,0" Size="80.80"  TextureOffset="0.0" Texture="assets\UI\Art\Notification\NotificationCSCaptureGlow.dds"  Pause="0" Cycle="Bounce" Speed="1" AlphaStart="0" AlphaEnd="1"/>
          <Label Anchor="C,C" Offset="0,0" String="" Font="TwCenMT20" ColorSet="Beige_Black_Alpha" FontStyle="Shadow" ID="CSCaptureCount" />
        </Button>
      </SlideAnim>
    </Container>
  </Instance>
</Context>
 
Do me a favor, and set VERBOSITY = 1 on NotificationPanel and CustomNotification

I want to see if it is actually running all of the functions in CustomNotification, and this will at least report that values are being set.
 
Oh! Did you create a NotificationRefugeesGlow.dds? Otherwise you are calling a graphic that does not exist.
 
I've corrected the dds error and set verbosity to 1, here's the output:

Code:
INFO   doCityCapture()
DEBUG  Partisans
DEBUG  Best unit: UNIT_WARRIOR
Refugees	Refugees fled Istanbul	Refugees from Istanbul fled to the [ICON_CAPITAL] Capital!	table: 16587CF0	0	Red
Icon Image Table: 	0
Notification Disabled
DEBUG   Displayed Notification

If it helps, I've attached the test map and compiled mod.
 
Hmm.

You found a bug in my code!

This is not properly working:
Code:
function IsNotificationEnabled(name)
	if NotificationOptionsEnabled == false then
		aprint("Notification Enabled")
		return true
	elseif Game.NotificationSettings then
		aprint("Notification Enabled")
		return Game.NotificationSettings.Settings[Game.CustomNotifications.NotificationTypes[namesToNotificationTypes[name]]]
	end
	aprint("Notification Disabled")
	return false
end

Change it to this:
Code:
function IsNotificationEnabled(name)
	if Game.NotificationSettings then
		aprint("Notification Options Test")
		return Game.NotificationSettings.Settings[Game.CustomNotifications.NotificationTypes[namesToNotificationTypes[name]]]
	end
	aprint("Notification Enabled")
	return true
end
 
Should BC - Events.lua be imported as an InGameUIAddin on the Content tab if I've got BC - NotificationsAddin.lua there as a NotificationAddin? I noticed this output:

...
NotificationPanel: NotificationOptionsEnabled pre-function= false
BC - NotificationsAddin: running notitypeinfo
BC - NotificationsAddin: Number of Notification Types: 1 notinumbers: 0
BC - NotificationsAddin: Number of TypeTab Entries: 1
BC - NotificationsAddin: tab info: CNOTIFICATION_REFUGEES Refugees
BC - NotificationsAddin: Notification Type: 55
BC - NotificationsAddin: Notification Name: CNOTIFICATION_REFUGEES
BC - NotificationsAddin: running notitypeinfo
BC - NotificationsAddin: Number of Notification Types: 2 notinumbers: 1
BC - NotificationsAddin: Number of TypeTab Entries: 2
BC - NotificationsAddin: tab info: CNOTIFICATION_CS_CAPTURE CSCapture
BC - NotificationsAddin: Notification Type: 56
BC - NotificationsAddin: Notification Name: CNOTIFICATION_CS_CAPTURE
File Error: BC - Events.lua
Runtime Error: Error loading BC - Events.lua.

NotificationPanel: Loaded Context: BC - Events
...
... later it loads the file as an InGameUIAddin
...
MODS\Thals Balance Mods - Combined (v 4)\Balance - Combat\BC - Events: Attempting to load BC - Events.lua
MODS\Thals Balance Mods - Combined (v 4)\Balance - Combat\BC - Events: Custom notification executed
MODS\Thals Balance Mods - Combined (v 4)\Balance - Combat\BC - Events: INFO Loaded BC - Events.lua
...

Somehow, I think namesToNotificationTypes is not getting initialized or passed properly to LuaEvents.NotificationChild, possibly due to me doing something wrong that results in that load error? I get this error when the notification runs:

CustomNotification.lua: 24: attempt to index global 'namesToNotificationTypes' (a nil value)
 
For the working versions I have, in each case, I just imported the actual function files to VFS. It seemed that if I did an InGameUIAddin, the file did not seem to always load before NotificationPanel.lua got through it's process.
 
Sounds like another good reason for some community standard for a mod to control load order, based off InGame.xml somehow. :)

Do you know of any downside to importing to the vfs? I'm rebuilding the project using that method for the event files and will try again.

Edit: Everything's working now! :dance:
 
I am not sure if the game operates slower if there is more file girth in the VFS, but I doubt it makes a noticable difference over UIAddins.

The only concern with importing to VFS is possibly 2 similarly named files overwriting each other.
 
Nice. When I did my testing, I made once that flashed between a wonder and the tech currently being research and one that showed the icon of a resource that just got hooked up and the icon of the civ that hooked it up.
 
Working on added functions that allow for Left Click to open a Popup.

Are there any other functions modders would want from their notifications?
 
Okay, so how would I go about properly overriding a notification? I'm trying this as a simple disable:

Code:
include( "CustomNotification" )

LuaEvents.NotificationOverrides({
  type="NOTIFICATION_STARVING",
  override=function(tooltip,summary,value1,value2)
    --LuaEvents.CustomStarving();
  end
};)
Code:
 Runtime Error: "NotificationPanel.lua":45: attempt to index field 'OuterStack' (a nil value)

One thing that'd actually be nice is to go without the automatic "left click to center" text added to notifications. It's the norm for notifications to left-click-center, so players already know about it, and it's best to let developers have full control over the tooltip.
 
Agreed. The popup would be more akin to notifications for things like learning a tech, or requiring choosing an option in a popup window.

First, as I mentioned in the top post, set all includes as "CustomNotification.lua". CustomNotification seems to be a common name, so the lua part stops the game from including the wrong thing.

Second, the event is NotificationOverrideAddin, which might explain that error. Once that is sorted out, it "should" work as intended.
 
Change the name; that's only going to cause headaches. Like where this is going, btw.
 
I will probably change the name in the next iteration, given that few people have fully implemented the system just yet. I just hate having to name things non-descriptive titles.
 
Back
Top Bottom