• Welcome to SC4 Devotion Forum Archives.

DAMN Development Thread (formerly known as "Custom Submenus")

Started by daeley, November 12, 2007, 02:28:25 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

z

Quote from: daeley on November 04, 2009, 09:30:01 AM
I was going to add a bit of code to the DAMN to make it possible to add a local root, when I realized it's already possible to do it with the current DAMN :P

Sounds good to me.  I'll change that in RTMT for the 3.70 release.

Quotethere you go, no ugly kludging of the code needed :p

It is a pretty ugly kludge, isn't it?  ::)  I'll be glad to see it go.  ;)

Stefan79

Hi daeley and all others,

first it seems the local root item is a useful thing, so I will add this feature to my SSPTool-DAMN Creator for easier using.

Second - I ask daeley for this - you could change the customMenu.dat with the following code, so it might be possible to use also MayorModePloppable from DAMN menu. I've checked this with buildings, network pieces and flora and it works!  :thumbsup:

DAMenu.newItem = function()
   item = {}
   item.menu = false
   item.hidden = false
   item.network = false -- maybe I should make a "type" field?
   item.type = "" -- here is the type field, we will keep the item.network for compatibility
   item.linkname = "item linkname"
   item.info = {}
   item.info[1] = ""
   item.info[2] = ""
   item.description = "item description"
   item.iid = "00000000"
   item.icon = DAMenu.icons.plop
   return item
end

DAMenu.itemCursor = function(item)
   if (item.network) then
     game.tool_plop_network(tonumber(item.iid,16))
   else
     if (item.type == 'flora') then
   game.tool_plop_flora(tonumber(item.iid,16))
     else
   if (item.type == 'network') then
     game.tool_plop_network(tonumber(item.iid,16))
       else
     game.tool_plop_building(tonumber(item.iid,16))
   end
     end
   end

end 

Of course I would change/implement this in my SSPTool-DAMN, so everyone can use it easily.

SSP = Stefan's Self-made Productions

daeley

Quote from: dragonshardz on November 04, 2009, 10:42:46 AM
daeley, care to elaborate more on the local root stuff? Perhaps a more in-depth tutorial?

well... not sure how much indepth I can go but I'll give it a try:
- add an empty file (e.g. Another.menu) to the menu folder you want to point to (from any other menu defined after this one)
- add the following code to the other menu:

local localroot = DAMenu.items["Another.menu"]
DAMenu.addItem(menu,localroot)

optionally you can also add code to create infotext [1] and [2], or a custom icon for this button

that's it :) this will add a button to menu that will redirect you to the folder where Another.menu is defined.
Of course, if Stefan ads this to SSPtool, it will be even simpler...

Quote from: Stefan79 on November 04, 2009, 11:27:34 PM
first it seems the local root item is a useful thing, so I will add this feature to my SSPTool-DAMN Creator for easier using.

Second - I ask daeley for this - you could change the customMenu.dat with the following code, so it might be possible to use also MayorModePloppable from DAMN menu. I've checked this with buildings, network pieces and flora and it works!  :thumbsup:

@first: that would be really nice, people seem to be discouraged to edit code by hand.

@second: really nice idea! There's only one problem: I lost the code to compile the DAMN installer &ops so I can't update it without rewriting the code for the installer (which is a tedious task &Thk/() Not sure how to proceed with this...
1. Install SC4+RH
2. Install LEX (CD&DVD helps) and latest NAM + updates
3. Play the game
4. ? ? ? ?
5. Profit!

Stefan79

Hi together,

@daeley
as you know I packaged your last customMenu.dat (19.01.09) with my SSPTool-DAMN.
I guess, the people use my program to create DAMN menus, so they can also install DAMN with my program and its not needed to make an extra installer.
This will also prevent to make any mistakes, automatically generate the index and works with all Windows versions (and maybe MacOS).

So, with your permission, I would add/change the lines in the customMenu.dat as listed in my last post and package it with my next version of SSPTool-DAMN which will be finished next Monday.
Beside I know "z" made a BiggerNewsWindows mod with an extra RTMT icon and always view regardless the Urgent Advice Dialogs are turned on. The only necessary change I found is the "a.priority = 0", so I would include this in the new customMenu.dat, too.
Will this be okay for you?

@z
With your permission I would package the three BiggerNewsWindow with my SSPTool-DAMN, so the user can not only install DAMN but choose a news size, too. The "local root" option will be implemented in my next program version, too, so there is no need to do more changes in the customMenu.dat.
Will this be okay for you?

Regards, Stefan
SSP = Stefan's Self-made Productions


z

Quote from: Stefan79 on November 05, 2009, 03:03:58 AM
@z
With your permission I would package the three BiggerNewsWindow with my SSPTool-DAMN, so the user can not only install DAMN but choose a news size, too. The "local root" option will be implemented in my next program version, too, so there is no need to do more changes in the customMenu.dat.
Will this be okay for you?

I think this is a great idea.  It will certainly make things simpler for RTMT, and hopefully for others as well.  I'll still leave the Bigger News Window as a separate download on the LEX, as many people like to use it just to see more of their news.  So yes, this is more than OK with me!  :thumbsup:

Stefan79

Hi together,

having spend some time trying and testing the various options for DAMN menus I come to this conclusions:

see here http://sc4devotion.com/forums/index.php?topic=6818.msg287605#msg287605

[EDIT](Deleted post as it is same in another thread but updated there)[/EDIT]

Best regards, Stefan
SSP = Stefan's Self-made Productions

shanghai kid

Love the new 2-column choice, as this helps finding lots easier then having to scroll a lot to find one that is down on the list.
Shanghai kid from Norway
"The lurking devil"
(Bam Bam Bigelow & Eddie Guerrero R.I.P).

daeley

1. Install SC4+RH
2. Install LEX (CD&DVD helps) and latest NAM + updates
3. Play the game
4. ? ? ? ?
5. Profit!

Stefan79

Hi together,

good and bad news:

:thumbsup:
- Have finished SSPTool with DAMN and will upload it today (I hope I have fixed all bugs and implement the things you requested)

:thumbsdown:
- Have cancelled the local root option in this version

The cancel of the local root option for now is because of some reason:
- I have to rewrite some more code as I thought, and so I will do this in the next new Plugin: DAMN-Management
- I think with the new option to choose more columns, bigger news size and more items for a submenu, it could be obsolete

For more information about the new options see my SSPTool Thread http://sc4devotion.com/forums/index.php?topic=6818

@z: sorry I haven't implement the local root option yet

Best Regards,
Stefan
SSP = Stefan's Self-made Productions

z

Quote from: Stefan79 on November 24, 2009, 11:42:03 PM
@z: sorry I haven't implement the local root option yet

No problem - my ugly kludge is working fine for now.  ;D  But although I definitely like the new features you've been adding, I don't think they make the local root obsolete at all.  I know that we will continue to use it in RTMT.  So I do hope that you will implement it in a future version.  Thanks!

plutino

I'm not sure if it's appropriate to post here, but since the problem only comes with DAMN but not other plugins, I'll give it a try.

I play sc4 with wine on a linux box.  So the DAMN menu popups well, but no item shows up in the menu.  I suspect that the cause maybe an in compatibility of the index file.  I have copied the index file from a windows installation in which the DAMN menu works fine.  On my wine box SC4 is installed to the same path as in the windows installation, so theoretically this should work, but it doesn't. 

I have tried to use a backslash to escape special characters in the index file [\, space, (, and )], no use.  I also tried to use a linux absolute path, which does, of course, not work. 

As I said at the beginning, this might be a problem with wine, but since it can be pinpointed to the DAMN index list, I'm wondering if there is any special requirement/assumption for the index file list in the code? 


Stefan79

Hi plutino,

if the DAMN menu popup but no items are shown this is a problem with the index file. But you can't simply copy the index file, cause the path might not be same as in the windows installation. Better is to run the Indexer script so the path will be correct.

You can also try my SSPTool which runs under JAVA to create the index, see http://sc4devotion.com/forums/index.php?topic=6818.0
SSP = Stefan's Self-made Productions

plutino

Thanks for the reply.  The reason I'm copying the index file is that there is no way to generate it under "wine" in a linux box (and I have also tried to generate the index file with your SSPTool in linux and fixed it by hand, by the way, it was a great tool).  As I've said, one thing I'm quite sure is that the path names in my linux installation and windows installation are exactly the same. 

As thus, I suspect that the problem is some special characters are dealt differently in native windows and in a wine simulator.  Thus if would be great if one of the DAMN creators can tell me how the index file is read.  E.g., the function call used to read the lines in the file in C, Java, or whatever language the program is written.



Quote from: Stefan79 on January 10, 2010, 11:29:21 PM
Hi plutino,

if the DAMN menu popup but no items are shown this is a problem with the index file. But you can't simply copy the index file, cause the path might not be same as in the windows installation. Better is to run the Indexer script so the path will be correct.

You can also try my SSPTool which runs under JAVA to create the index, see http://sc4devotion.com/forums/index.php?topic=6818.0


Stefan79

Hi Plutino,

DAMN is not an extra program but a normal SimCity Dat file (format DBPF) which includes a script entry in the language LUA. The lines that reads and interpret the index files are the follow:

...
-->> build from directory structure <<--

function DAMenu.interpret(path)
  local _,i = string.find(path,"Root\\")
  local relpath = string.sub(path,i+1)
  local menu = DAMenu
  while (i) do
    _,i = string.find(relpath,"\\")
    if (i) then 
      local folder = string.sub(relpath,0,i-1)
      -- interpret folder
      local submenu = menu.items[string.lower(folder)]
      if (not submenu) then
        submenu = DAMenu.addMenu(menu,folder)
      end
      menu = submenu
      relpath = string.sub(relpath,i+1)
    end
  end
 
  -- create link from root to relative menu
  DAMenu.items[relpath] = menu
end

-- os.execute("echo off & del list.txt & for /R %i in (*.damn.lua) do echo %i >> list.txt") -- game loses focus :(
local luainput = io.open([[Plugins/DAMN/Support/DAMN-index.txt]])
local line = 1
while (line) do
  line = luainput:read("*l")
  if (line) then
   DAMenu.interpret(line)
  end
end

DAMenu.currentMenu = DAMenu
end


Lines starting with "--" are comments and not recognized and the main important things of reading the file is the open function of LUA. I don't know much about LUA, so I can't tell you, if there is any chance to read the index under Wine. If I have some time I could test some things: Changing \\ with / and so on, because this character cause often problems between Windows and Linux.
Maybe Daeley could tell more.

Stefan
SSP = Stefan's Self-made Productions

daeley

when defining a string of characters, for example in string.find(relpath,"\\"), the string "\\" looks for a single backslash in the original file. This is because you can look for special characters with a backslash (e.g. "\n" is the newline char, "\t" is the tab char), so a backslash must be written as a double backslash.

So, as long as all paths are written with single backslashes in the index script (i.e. C:/Program Files/Simcity 4/Plugins/DAMN/Root/...) it should work. The only problem I can think of is that it is not correctly loading the index script itself. You could try the following: open the DAMN main file with Ilive's Reader, look for the indexing code and replace Plugins/DAMN/Support/DAMN-index.txt with Plugins\\DAMN\\Support\\DAMN-index.txt
1. Install SC4+RH
2. Install LEX (CD&DVD helps) and latest NAM + updates
3. Play the game
4. ? ? ? ?
5. Profit!

plutino

Thanks daeley and stefan.  I'll try to dig it a little bit.

plutino

I managed to get it to work under wine by replace the relative path to the index file with an absolute path.  i.e. replace the line
local luainput = io.open([[Plugins/DAMN/Support/DAMN-index.txt]])
with
local luainput = io.open("C:\\Program Files\\Maxis\\SimCity 4 Deluxe\\Plugins\\DAMN\\Support\\DAMN-index.txt")

Thanks to both Daesey and Stefan for the help!

Quote from: daeley on January 13, 2010, 03:16:04 AM
when defining a string of characters, for example in string.find(relpath,"\\"), the string "\\" looks for a single backslash in the original file. This is because you can look for special characters with a backslash (e.g. "\n" is the newline char, "\t" is the tab char), so a backslash must be written as a double backslash.

So, as long as all paths are written with single backslashes in the index script (i.e. C:/Program Files/Simcity 4/Plugins/DAMN/Root/...) it should work. The only problem I can think of is that it is not correctly loading the index script itself. You could try the following: open the DAMN main file with Ilive's Reader, look for the indexing code and replace Plugins/DAMN/Support/DAMN-index.txt with Plugins\\DAMN\\Support\\DAMN-index.txt

hconline

So... um yeah, DAMN would be great.... If I could get the damned thing to work. (sorry, bad pun)

I've been trying to get the DAMN to work for a week, no results. The menus keeps showing up blank. I've got the SC4 shortcut set up right so that it doesn't have \Apps. I've got DAMN un-datpacked in the program files\maxis\(sc4)\plugins folder. I've tried removing all the menus I made with SSPTool, I've tried uninstalling and reinstalling, I've tried reindexing... Just about everything. Any ideas to get a menu that actually has things on it?
Life is like a butterfly, ephemeral, yet beautiful beyond belief. -Me

Diggis

Are you using windows Vista?  Further back in this thread is an explanation of why it doesn't work, and a fix.

In this post here:

http://sc4devotion.com/forums/index.php?topic=2917.msg282070#msg282070