Thought I'd share a .bat file I wrote for executing the latest KoLmafia-*.jar build

Ulti

Member
My setup looks something like:

kolmafia/scripts/
kolmafia/relay/
kolmafia/KoLmafia-16261.jar
kolmafia/KoLmafia-16396.jar

Eventually, I got sick of navigating to my kolmafia directory and finding the latest jar file to open,
so I wrote a .bat file to open the latest jar file.
Code:
@echo off
setlocal enabledelayedexpansion
set max=0
for %%x in (KoLmafia-*.jar) do (
  set "FN=%%~nx"
  set "FN=!FN:KoLmafia-=!"
  if !FN! GTR !max! set max=!FN!
)
start KoLmafia-%max%.jar
Store that in in your kolmafia directory. Now opening it will pull-up the windows command prompt for a split second while it opens the latest jar for you.

I decided to get a bit fancy with it. We don't wanna see a command prompt pop up even for a split second, so I created a shortcut on my desktop to the .bat file. Right click the shortcut's properties and choose to run the file minimized. Finally, the .bat default icon is a bit boring. KolMafia has a dedicated icon already with its .exe file, so I decided to use that. You can either store the .exe in your kolmafia directory then set the shortcut icon to the .exe file where you should be able to pick the limeglass image as your icon.

Ooooor, you can do what I did and generate a higher-quality icon by navigating to src/images/limeglass.gif in the mafia source or util/macosx/limeglass.icns in the mafia source then converting one or the other to an .ico which I did with https://iconverticons.com/online/
Name the icon limeglass.ico and store it in your kolmafia directory. Finally set your shortcut icon to use the limeglass.ico file you generated.

For your convenience, here's a zip with the .bat file and the .ico:
 

Attachments

  • mafia.zip
    51.2 KB · Views: 52
Last edited:

Theraze

Active member
Huh... my KoL.bat is just this:
Code:
@KoLMafiaUpdate.exe
Downloads and runs the newest .jar file...
 

fronobulax

Developer
Staff member
Global preference

loginWindowLogo=limeglass.gif

lantern.gif is the other option I recall as being valid out of the box.

While I appreciate the effort, my update and run procedures need to be separate. Just launching the jar file from the OS works well for me.
 

Bale

Minion
loginWindowLogo=limeglass.gif

I had no idea I could do that! It's not an amazing image, but I cannot begin to tell you how tired I am of lantern.gif so I adore my new skin for the KoLmafia login window!

Can I do that with other images of the correct size if I put them in /images?
 

fronobulax

Developer
Staff member
I had no idea I could do that! It's not an amazing image, but I cannot begin to tell you how tired I am of lantern.gif so I adore my new skin for the KoLmafia login window!

Can I do that with other images of the correct size if I put them in /images?

It would be worth a shot but I need to look at the code to see whether there is an assumption that the loginWindowLogo is in the jar file or somewhere else. If the the former a FR to check for an image on disk first might be within my ability to execute.

I remember it because I do not like the lantern. I vaguely recall that when hola was building the releases he would switch images and I remember tracking down how so I could undo the lantern. Of course to be fair, I hardly notice the image these days but it was important at one time.
 

Ulti

Member
That's right Bale, anything in the /src/images directory can be used with loginWindowLogo.
No fronobulax, it doesn't use a jar, but it does hard-code the directory it uses:
LoginFrame.java
Code:
	public JPanel constructLoginPanel()
	{
		String logoName = Preferences.getString( "loginWindowLogo" );

		if ( logoName.endsWith( ".jpg" ) )
		{
			logoName = logoName.substring( 0, logoName.length() - 4 ) + ".gif";
			Preferences.setString( "loginWindowLogo", logoName );
		}

		JPanel imagePanel = new JPanel( new BorderLayout( 0, 0 ) );
		imagePanel.add( new JLabel( " " ), BorderLayout.NORTH );
		imagePanel.add(
			new JLabel( JComponentUtilities.getImage( logoName ), SwingConstants.CENTER ),
			BorderLayout.SOUTH );

		JPanel containerPanel = new JPanel( new BorderLayout() );
		containerPanel.add( imagePanel, BorderLayout.NORTH );
		containerPanel.add( this.loginPanel, BorderLayout.CENTER );
		return containerPanel;
	}
JComponentUtilities.java
Code:
	public static ImageIcon getImage( final String filename )
	{
		return JComponentUtilities.getImage( UtilityConstants.IMAGE_DIRECTORY, filename );
	}
UtilityConstants.java
Code:
public static final String IMAGE_DIRECTORY = "images/";
I think it would be interesting, though, if you could change the directory by making slashes in the loginWindowLogo setting meaningful, rather than just hard-coding the directory.
 
Last edited:

lostcalpolydude

Developer
Staff member
I think it would be interesting, though, if you could change the directory by making slashes in the loginWindowLogo setting meaningful, rather than just hard-coding the directory.

That would first require the setting to be added to the GUI somewhere, and made unchangeable outside the GUI (not hard to do, but it would be a deliberate change). Otherwise KoLmafia scripts can set that to an arbitrary, potentially malicious file, and possibly do more than ruin your KoL character as the worst case scenario.
 

Bale

Minion
I put an image in /images/relayimages/ to avoid cache clear and it worked quite well from there. That seems to me the only additional directory that anyone would need for this purpose.

set loginWindowLogo = relayimages/kingdom_of_loathing_by_catsup.png
 

Ulti

Member
OH! I just found another great possibility when I resize this: http://s180.photobucket.com/user/emd_art/media/ma_wall.jpg.html
I kind of like that one.

Does anyone, which is good with graphics, wanna try drawing KolMafia a new login banner? I'd advise brainstorming first regarding what should go on it. Work on some sketchings, then when you know what to do, make some final adjustments to the sketching, color it in, either on paper, your computer, or a combination of the two, apply finishing touches, and share it with us so a developer here can add it to Mafia.

I could do it, but it would take me weeks to produce something worthy of going into Mafia. With some commitment, the best banner I ever drew was: http://i4.ifrm.com/5987/84/upload/p996728.gif
(notice how badly I drew the phoenix's head and how badly it affected the final product below)
http://i4.ifrm.com/5987/84/upload/p3581882.jpg
Which is so-far so good, but then when trying to add text to it, representing the message forums I built it for, the text was chopping off the phoenix's head:
http://i4.ifrm.com/5987/84/upload/p5286461.jpg
A contact of mine, at the time, tried making the text more transparent:
http://i4.ifrm.com/5987/84/upload/p5286424.jpg
but not much improvement. I suppose the final product isn't so bad considering the site needed a banner at the time and nobody wanted to take on the job.
But I'm a web developer, not a graphics designer, so there's definitely someone around here better-suited for the job.
Anyone up for the challenge?
 
Last edited:

Bale

Minion
OMG! Check out my login window now!

3oVhU8W.jpg
 

fronobulax

Developer
Staff member
No fronobulax, it doesn't use a jar, but it does hard-code the directory it uses:

Thanks. You were looking at the code and I had not yet done so. I made a guess based upon my inability to quickly find limeglass.gif on my file system.

In light of the fact that this is a preference I am waiting for someone to script something that randomly selects an image from a source directory and uses it as the Login Image...
 

Bale

Minion
I've now got a selection of eight pretty login images and a function in my loginScript which cycles between them so that I can see a different image every time I log in to KoLmafia. It's fun!~ I can't believe I never learned how to do this before!

:D :D :D
 

Theraze

Active member
The easiest way to do it is to simply work on a switch that looks at the preference and selects the next one. It's no random selector, but it does allow for round-robin (or random, if you change the switch value) login images.
 

Bale

Minion
My method is better because it is easier to reorder, add and remove new images, though the principle of choosing the next in line after the current is similar:

Code:
void loginWindowLogo() {
	string [int] img;
		img[ count(img) ] = "relayimages/loginWindowLogo/kingdom_of_loathing_by_catsup.png";
		img[ count(img) ] = "relayimages/loginWindowLogo/KoL_comicon2008_display.png";
		img[ count(img) ] = "relayimages/loginWindowLogo/emd_art_wall.png";
		img[ count(img) ] = "relayimages/loginWindowLogo/Lagomorpho_preCalendar2012_Ascension.png";
		img[ count(img) ] = "relayimages/loginWindowLogo/Lagomorpho_Bone_Star_preCal2012.png";
		img[ count(img) ] = "relayimages/loginWindowLogo/comic_kickstarter_town.png";
		img[ count(img) ] = "relayimages/loginWindowLogo/ilitchev_preCal2013.png";
		img[ count(img) ] = "relayimages/loginWindowLogo/Master_Grimwulf_The_Avatars_Three_preCal2015.png";
	string loginWindowLogo = get_property("loginWindowLogo");
	foreach x,i in img
		if(i == loginWindowLogo) {
			int nex = count(img) > x + 1? x + 1: 0;
			set_property("loginWindowLogo", img[nex]);
			return;
		}
	set_property("loginWindowLogo", img[0]);
}
 
Last edited:

Bale

Minion
For completeness, here's the 8 images I resized and/or cropped to a maximum width of 480 pixels.
http://imgur.com/a/MKiK7

If anyone else has other images to suggest. I'd like to see them.
 
Last edited:

Theraze

Active member
And if you love the idea of random images, just do something like:
Code:
void loginWindowLogo() {
	string [int] img;
		img[ count(img) ] = "relayimages/loginWindowLogo/kingdom_of_loathing_by_catsup.png";
		img[ count(img) ] = "relayimages/loginWindowLogo/KoL_comicon2008_display.png";
		img[ count(img) ] = "relayimages/loginWindowLogo/emd_art_wall.png";
		img[ count(img) ] = "relayimages/loginWindowLogo/Lagomorpho_preCalendar2012_Ascension.png";
		img[ count(img) ] = "relayimages/loginWindowLogo/Lagomorpho_Bone_Star_preCal2012.png";
		img[ count(img) ] = "relayimages/loginWindowLogo/comic_kickstarter_town.png";
		img[ count(img) ] = "relayimages/loginWindowLogo/ilitchev_preCal2013.png";
		img[ count(img) ] = "relayimages/loginWindowLogo/Master_Grimwulf_The_Avatars_Three_preCal2015.png";
	set_property("loginWindowLogo", img[random(count(img)-1)]);
}
 

Theraze

Active member
Only works if you have 8 characters... Unless you save your round-robin to a separate preference which is only read on those even days and the next item is selected then.
 
Top