• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

List Resource - New Submission Style?

Status
Not open for further replies.
Level 31
Joined
Jul 10, 2007
Messages
6,306
What I have here is possibly a new submission style and way to organize code. Rather than include the code in the map, I include the code in a map folder. The map folder contains both the map (in this case the demo map) and the resource folder (plus all required resource folders). With this, cnping a resource into a map is just about cnping all of the folders that come with the demo map and including the 1 resource you want. That one resource should automatically import all required resources. Pretty nifty eh?


There are some other added benefits. No more multiple triggers to CnP. Organize code across several folders and files to make things easier to read and manage. GitHub your projects more easily. Need I say more? lol.


So please give feedback on how you like this new style. Also, for this new style of List, please give feedback on the address in the API. Address is for memory tracking, for memory leaks and stuff. Right now only the collection itself is being given an address. Given that nodes can also get data, should nodes be given an address too? For example, if you created a unit for a specific node, wouldn't you want that node to track the unit? What happens when the node is removed but the unit isn't removed? Shouldn't a leak be thrown if the node is still tracking that unit?

Tx
 

Attachments

  • ListHtNt.7z
    98 KB · Views: 100
Level 6
Joined
Jul 30, 2013
Messages
282
this is bit weird..
JASS:
		public static method getAllocatedMemoryAsString takes nothing returns string
			return Allocator.getAllocatedMemoryAsString()
			return Allocator.getAllocatedMemoryAsString()
		endmethod

now back to the topic at hand..

i think it would actually be a good idea to have some standardised package management infractructure.

sure having actual code files beats binary blobs +1 for this.
but i think its bout time we get sth like pip or npm or the like.
 
Level 31
Joined
Jul 10, 2007
Messages
6,306
Right now I'm working on such a file structure : ).

Every script will also have an install.bat and uninstall.bat =O.


Here's my current bat file that I've been working on. This can select folders, read and modify the registry, and uhm... >.>.

I suck at bat fyi.

Code:
@echo OFF

set path=%~1
set pathType=NUL
set pathName=NUL
set pathExt=NUL
set selectedFolder=NUL
set value=NUL

call:getPathType "%path%" pathType
call:getPathName "%path%" pathName
call:getPathExtension "%path%" pathExt

echo path:      %path%
echo type:      %pathType%
echo name:      %pathName%
echo extension: %pathExt%

set concat=%pathName%%pathExt%
echo %concat%

::call:selectFolder selectedFolder
::echo %selectedFolder%

::call:readReg "HKEY_CURRENT_USER\Software\Grimoire\Disable vJass syntax" value
::echo value: %value%

::"REG_SZ" for string
::"REG_DWORD" for integer (32-bit)
::"REG_QWORD" for integer (64-bit)
::"REG_BINARY" for binary or boolean
::"REG_EXPAND_SZ" for expandable string
::call:writeReg "HKEY_CURRENT_USER\Software\Grimoire\Custom" "test" "REG_SZ"

::call:deleteReg "HKEY_CURRENT_USER\Software\Grimoire\Custom"

pause
goto:eof

:: directories in current directory
:: for /D %%s in (%~1\*) do @echo %%~s

:: all files in current directory
:: for %%f in (.\*) do @echo %%~f

:getPathType
::					-- %~1: path
::					-- %~2: return INVALID, FILE, DIRECTORY
SETLOCAL ENABLEEXTENSIONS
set pathType="Invalid"

if not exist "%~1" (
	set pathType=INVALID
) else (
	set attribute=%~a1
	set dirAttribute=%attribute:0,1%
	
	if "%dirAttribute%"=="d" (
		set pathType=DIRECTORY
	) else (
		set pathType=FILE
	)
)

(ENDLOCAL & REM -- RETURN VALUES
	set %~2=%pathType%
)
GOTO:EOF

:getPathName
::					-- %~1: path
::					-- %~2: return name
set %~2=%~n1
GOTO:EOF

:getPathExtension
::					-- %~1: path
::					-- %~2: return extension
set %~2=%~x1
GOTO:EOF

:selectFolder
::					-- %~1: return value
	for /F "Tokens=1 Delims=" %%I in ('C:\windows\system32\cscript.exe //nologo "%cd%\browseFolder.vbs"') do set %~1=%%I
GOTO:EOF

:readReg
::					-- %~1: path
::					-- %~2: return value
	for /F "Tokens=1 Delims=" %%I in ('C:\windows\system32\cscript.exe //nologo "%cd%\registry.vbs" "read" "%~1"') do set %~2=%%I
GOTO:EOF

:writeReg
::					-- %~1: path
::					-- %~2: value
::					-- %~3: valueType
	C:\windows\system32\cscript.exe "//nologo" "%cd%\registry.vbs" "write" "%~1" "%~2" "%~3"
GOTO:EOF

:deleteReg
::					-- %~1: path
	C:\windows\system32\cscript.exe "//nologo" "%cd%\registry.vbs" "delete" "%~1"
GOTO:EOF

Code:
function ReadReg(path)
	Dim WSHShell, value

	On Error Resume Next
	Set WSHShell = CreateObject("WScript.Shell")
	value = WSHShell.RegRead(path)

	if err.number <> 0 then
		value=Null
	end if

	set WSHShell = Nothing
	
	ReadReg = value
end function

'Regtype should be “REG_SZ” for string, "REG_DWORD" for a integer,…
'”REG_BINARY” for a binary or boolean, and “REG_EXPAND_SZ” for an expandable string
Function WriteReg(path, value, valueType)
	Dim WSHShell, Key
	
	On Error Resume Next
	Set WSHShell = CreateObject("Wscript.shell")
	Key = WSHShell.RegWrite(path, value, valueType)
	
	set WSHShell = Nothing
	
	WriteReg = Key
End Function

Function DeleteReg(path)
	Dim WSHShell, Key
	
	On Error Resume Next
	Set WSHShell = CreateObject("Wscript.shell")
	Key = WSHShell.RegDelete(path)
	
	set WSHShell = Nothing
	
	DeleteReg = Key
End Function

if (WScript.Arguments(0) = "read") then
	Wscript.Echo ReadReg(WScript.Arguments(1))
elseif (WScript.Arguments(0) = "write") then
	Wscript.Echo WriteReg(WScript.Arguments(1), WScript.Arguments(2), WScript.Arguments(3))
elseif (WScript.Arguments(0) = "delete") then
	Wscript.Echo DeleteReg(WScript.Arguments(1))
end if

Code:
Const MY_COMPUTER = &H11&
Const WINDOW_HANDLE = 0
Const OPTIONS = 0

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(MY_COMPUTER)
Set objFolderItem = objFolder.Self
strPath = objFolderItem.Path

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.BrowseForFolder _
    (WINDOW_HANDLE, "Select a folder:", OPTIONS, strPath)
     
If objFolder Is Nothing Then
    Wscript.Quit
End If

Set objFolderItem = objFolder.Self
objPath = objFolderItem.Path

Wscript.Echo objPath


My idea is this. You drag your map on to the main bat and it'll automatically create a project folder for it plus place it in the project folder. This project folder will include an import JASS file, which is imported into the map (starts out empty) and a compile.bat file. The compile.bat will compile the scripts and put them into the map (it just runs jasshelper). I'll also include a run.bat.

The bat file will be able to locate grimext, jasshelper, and wc3 installation.


Next, for resources. Every resource will be in its own folder in a zip. A zip will contain all required resources. To install a resource, simply drag all of the contents of the zip into your project folder and then go to the resource you want and click install.bat. To uninstall, click on uninstall.bat. This will dynamically run installation scripts of all required resources that haven't already been installed and install itself. This includes generating any objects and including any scripts. The scripts are included in that special jass include folder. A table will store all included scripts and dependencies (for automatic uninstallation) as well as objects.


This structure will let you fully use GitHub and work on teams. It also makes resource installation much easier.



Also, I've been sure to make all of this with compatibility in mind. 64-bit, 32-bit, and whatever Windows OS probably back to XP =).
 
It is cool as a tool for team dev. As for replacing submissions, I don't see eye-to-eye on that matter.

It takes practically the same time as copying a folder from a demo map to your own map. The downside is that it enforces a structure that migrates away from the trigger editor. When you have things set up through //! import commands, it references files on your computer (not in the trigger editor). This means that to view/edit the files, you'll have to navigate to your computer files. It has its benefits, but I imagine it will also be a hinderance to the standard map maker.

This sort of system isn't inherently bad. After all, it is sort of similar to the structuring in Wurst. But why does it work better for Wurst? Because they have a dedicated IDE, compilation stages, etc. Without those tools, I don't see this sort of system becoming popular. Even then--if the user goes that far--why not use Wurst?

A better tool would be something along the lines of homebrew. Perhaps a preprocessor that will grab data from a repo (e.g. hive's resources) and replace the text in the trigger editor with it. I could see that becoming useful. It would just be a simple command. No migration needed, no extra tools, no real user effort besides typing in a simple command: brew install TimerUtils, for example.

I still think it is fine for you to work on it as a tool for those who desire that structure. I wouldn't personally enforce it upon users though. It didn't quite work well for Lua either. It has to be something that requires minimal user effort so it merges seamlessly with their workflow.
 
Level 31
Joined
Jul 10, 2007
Messages
6,306
I was thinking of this as a per project thing, not a global thing for all projects. Global things make it more difficult to work in teams and share things after all ; ). The problem with my Lua thing was that I tried to make it a global thing rather than a per map thing. I mean, if the stuff was automatically retrieved, like in Linux, that'd be ok I guess, but Linux is still a nightmare compared to Windows because the stuff is all shared rather than packaged for each thing ;).


If all I had to do to get UnitIndexer was download the zip, extract it, and hit Install (pretty much a Windows Installer), I think that'd be pretty brilliant. I mean, I could even go for full on installers if ya want, haha. That'd do the extraction for you : P.
 
Level 6
Joined
Jul 30, 2013
Messages
282
definitely as much as can be done to take things out of the map archive im all for it.

unrelated, the bat file looks kind of nice.. tho i cant help but wonder if it would be better to perhaps piggy-back on some system that already exists. well at least for some parts (theres no system that extracts/imports from mpq archives that i know of)

hmm perhaps like make it a composition of 2 separate scripts, 1st abuse some package manager (like pip but overriding the package index to some custom server) and another to deal with importing the tings in to the map when you want to make a release.

tho 1 thing that still bothers me. all the objects/abilities etc. it would be nice if there was a way to externalise them too (would make git more applicable, versioning 1 gigant blob is really sad, is making me cry :'( )


Also, i agree 1 thing that rly is a bit of a bother with many systems out there, is that just copy-pasting them is not enought to rly include them, theres often a lot of manual setup required. (eg set up what unit u use as dummy etc, and these are tedious and error prone activities, it would be nice if these could be automated to some extent)
 
Status
Not open for further replies.
Top