The Dink Network

New Development File: browser editor

May 14th 2018, 07:17 PM
custom_king.png
redink1
King He/Him United States bloop
A mother ducking wizard 
Our favorite developer-who-posts-interesting-python-related-tools-to-the-forum, shevek, has released a new Dink Smallwood editor by the name of browser editor.

"Why would I use this when I have Windinkedit?" I hear you ask. "Hey, how did Dan tap into my microphone? This is getting creepy," I hear you continue.

Anyway, this editor is a little bit different than most, in that it runs in your web browser. This means that it works fairly well in a Linux operating system.

So, give it a whirl, and let shevek know what you think.

May 15th 2018, 02:25 PM
pq_cthunik.gif
GOKUSSJ6
Peasant He/Him Poland
Everyone should get a pizza for free in each week. 
Still waiting for the cross platform version of WinDinkEdit+.
May 16th 2018, 10:56 AM
spike.gif
SlipDink
Peasant He/Him United States bloop rumble
2nd generation. No easy way to be free. 
As a Linux user, the idea that I might be able to get rid of my Wine installation that I'm using to run WindinkeditPlus2.exe, appealed to me. However, I'm not having much luck with getting this editor to work.

#1 When I load the editor.html file into FireFox 60.0 (64-bit) on Unbuntu 16.04, the tab for it changes to "Dink Mod Editor" and the web page remains 100% a blank white page. Since it is true that "by default, Firefox enables the use of JavaScript and requires no additional installation", I don't think there is anything wrong with Javascript on this system.

#2 I'm not certain that the "rather large useless subdirectory" that "has been removed" in the 0.2 May 2nd, 2018 version was actually removed.

When I unzip the browser_editor-0_2.zip file it produces this directory:
50 Megabytes dink (a directory)
112 Kilobytes editor (a directory)
430 bytes editor.html (an .html file)

But, perhaps the 50 megabyte dink directory is meant as a sample?

May 16th 2018, 05:12 PM
peasantm.gif
shevek
Peasant They/Them Netherlands
Never be afraid to ask, but don't demand an answer 
#1: It may take a while, but it should eventually show the map. Did you open the debugging console (ctrl-shift-k), and does is show any messages?

One thing that may be a problem: all filenames must be lowercase.

#2: No, unfortunately the dink directory is required. It contains all the assets from the main game. Those can be used in a D-Mod without bundling them. This means the editor needs to bundle them or else it wouldn't be able to display them. They are modified slightly (dir.ff files have been unpacked, and filenames have been converted to lowercase), otherwise the location of the main game could have been used (/usr/share/games/dink/dink on Debian; probably the same on Ubuntu).

The 0.1 version contained an "orig" directory by accident which contained mostly the same things as the dink directory, in a format that this editor doesn't understand. So that was truly useless.

And one correction to Redink's introduction: Because I made it for a web browser, it will not only work on Linux, but possibly also on Windows. Not the other way around. I don't have Windows, don't want it, don't test on it and don't really care all that much about it. But if people use it and my programs work on it, that's good.
May 17th 2018, 12:21 PM
spike.gif
SlipDink
Peasant He/Him United States bloop rumble
2nd generation. No easy way to be free. 
Okay, I can see now that my initial startup (loading editor.html) as a test was bound to fail, as I did not start it in my ~/dmod directory with ?[dmod-name] at the end of the URL. I was hoping to just get a rough idea of it's functionality without actually loading a dmod. But, I understand now that this would not work.

Anyway, it took quite a while to load up a small dmod and (from what I could tell) it did not seem to have all the tabs working when complete. But then I suppose you know that, right? The [World] tab showed nothing but a blank light tan-brown web page. The [Frame] and [Animation] tabs each showed a white web page. The [Tile] tab seemed to display the one tile in question in the small dmod I loaded. But nothing else seems to work.

Due to the fact that Dink.ini, DINK.INI and dink.ini all are considered as valid forms of filenames for dmods is something else that seems to get in the way of this editor working. This is especially tue of older dmods of course. I realize that you already mentioned that limitation. So, this morning, I wrote this short script that I named "lower.sh" (see below) that you might want to bundle with your editor.

#!/bin/sh
# This shell script converts all file and directory names
# under the passed in directory to lower case. It should
# work (perhaps with some light modification) for any
# *nix like operating system with a bash-like shell. It 
# assumes full write privileges to all files it processes
# and that no file or directory names have spaces in them.
#
# Assign EDITOR to the name of your favorite text editor.
#
EDITOR=`which gvim`
#
# SlipDink Thu May 17 10:22:07 EDT 2018
#
SCRIPT=`basename $0` 
HOSTNAME=`hostname |awk -F\. '{print $1}'`
USERNAME=`whoami`
VERSION=1.0a
TMP=/tmp/$SCRIPT.tmp
LOG=/tmp/$SCRIPT.log
START=$1
if [ -z "$START" ]; then
	START="."
fi
if [ -d "$START" ]; then
	true
else
	echo Does the [$START] directory exist?
	exit	
fi
FOUNDSOME=1

doitdir () {
	OLDNAME="$1"
	SAVEWORKINGDIR=`pwd`
	DIR_TO_RENAME=`echo $OLDNAME | awk -F\/ '{print $NF}'`
	DIRSABOVE=`echo $OLDNAME | awk -F\/ '{for (i = 1; i< NF; i++) {if (i==1) {printf("%s", $i)} else {printf("/%s", $i)}}}'`

	echo cd $DIRSABOVE
	cd $DIRSABOVE
	NEWNAME=`echo $DIR_TO_RENAME | tr "[:upper:]" "[:lower:]"`
	if [ "$NEWNAME" != "$DIR_TO_RENAME" ]; then
		mv -v "$DIR_TO_RENAME" "$NEWNAME"
		FOUNDSOME=`expr $FOUNDSOME - 1`
	fi
	cd $SAVEWORKINGDIR
}
	
doitfile () {
	OLDNAME="$1"
	NEWNAME=`echo $OLDNAME | tr "[:upper:]" "[:lower:]"`
	if [ "$NEWNAME" != "$OLDNAME" ]; then
		mv -v "$OLDNAME" "$NEWNAME"
	fi
}
	
#main
{
echo "Running version $VERSION of $SCRIPT on $HOSTNAME for $USERNAME."
doitdir "$START"
RESTART=`echo $START | tr "[:upper:]" "[:lower:]"`
FOUNDSOME=1
cd $RESTART
until [ "$FOUNDSOME" -eq 0 ]; do
	find . -type d -print|grep  "[A-Z]"|awk '{print length($1)"\t"$1}' |sort -rn |cut -d' ' -f2- >$TMP
	FOUNDSOME=`wc -l $TMP|awk '{print $1}'`
	while read "i"; do
		i=`echo $i |awk '{print $2}'`
		if [ "$i" != "." ];then
			doitdir "$i"
		fi
	done <$TMP
done

find $RESTART -type f -print|sort >$TMP
while read "i"; do
	doitfile "$i"
done <$TMP
/bin/rm $TMP
} 2>&1 |tee $LOG 2>&1

$EDITOR $LOG &


At this point, I think I'll wait for a later release to continue testing this editor. I want to try to get my next dmod ready in time for the contest.

May 17th 2018, 01:18 PM
peasantm.gif
shevek
Peasant They/Them Netherlands
Never be afraid to ask, but don't demand an answer 
I was hoping to just get a rough idea of it's functionality without actually loading a dmod. But, I understand now that this would not work.

That's probably useful once actual editing is supported; at the moment you can only view, and viewing an empty D-Mod seems useless.

I will say that an error message would be nice though.

Yes, the lowercase limitation is unfortunate. It's a side effect of the inability of web pages to request a list of files. So I can see if a file exists, but I can't check the list if any of the available files is the name I'm looking for when converted to lowercase. Looping through all options would be too ineffecient.

Thanks for the script. I wrote a Python script for doing the same thing before. Not sure if I kept it. Anyway, the problem with those scripts is that they don't run on every system. On the other hand, I don't think Windows users need it, because their filesystem is not case sensitive.

it did not seem to have all the tabs working when complete.
The sprite and screen properties and frame and animation edit tabs should just have a word of text in them so I can see that they are present; the content does not work indeed.

The world tab should work. If you don't see anything, that's probably because you don't have map screens defined near the center of the map. Zoom out (- key) and pan (drag while holding alt) to see more; the tiles and sprites should be rendered.

it took quite a while to load up a small dmod
This is because it loads the entire D-Mod into memory. In particular all graphics that are defined in dink.ini are loaded and converted to a format that allows using them on the world map. How long this takes does not depend on the size of the map, but on the number of available images. Since even small D-Mods usually include all of the original game's graphics, it takes a while.

On the up side, it doesn't take longer when the D-Mod is larger.

I think I'll wait for a later release to continue testing this editor. I want to try to get my next dmod ready in time for the contest.
Totally understandable. I hope you can just check if you can view the map though; it works for me, so I hope it works for others as well.

Also, the editor currently can't do much other than viewing the map (and finding bugs in ini files), so you definitely shouldn't try to use it to actually make your D-Mod.