Posts Tagged ‘swing’

Trekwar shipdesigner demo

Friday, March 13th, 2009

Almost done for the Trekwar shipdesigner which allows you to custom fit your star ships with available components.

Trekwar GUI updates

Tuesday, February 3rd, 2009

Recently much of my spare time programming has gone to giving the Trekwar client a graphical overhaul.

Now I’ve managed to get most of what I broke, working again (Research and Starsystem Control), and I’ve added a glasspane that shows up and prevents the clicking of buttons (and thus creating a weird state of the client) while each tick is being processed by the server.

trekwar_feb09_01
Currently the test galaxy is 100×100 tiles and takes about 0.5 seconds to load to client

trekwar_feb09_02

Unlike the previous version of the game, it is now possible to have many windows active on top of the actual game map.
The system box (far left of the screen) has been changed to display more information, and next up is a complete redesign of the fleet box.

But before making the new fleet box and fleet management system, I’ll have to do some major rewrite of the internal ship system and logic, to support user created ship classes.

I’m looking forward to 8-10 hours of pure java and logic.. There is only so much Swing a man can take :)

The path we choose

Wednesday, January 28th, 2009

Recently I’ve been continuing on my Star trek game, and doing part 2 of the GUI updates, I have to fix up the research view, as it was broken by the new UI.

I also made a new starship path system, and optimized some slow stuff in the drawMap() function

trekwar_path_old
old design – aka: stupid dot system

trekwar_path_new
new design – aka: ehm.. yellow lines?

After making the research view work again, it’s time to port the old starsystem administration UI into the new design. Followed by the new shipdesigner feature.

Back from sweden

Monday, January 28th, 2008

I was in Åre Sweden this weekend, on a company excursion by Betradar (where I’m starting work Friday).
Cabin, Sweden

They had rented a large cabin (250 m2), and around 20′ish employees hang out there from Friday to Sunday. I got to meet some of my soon to be coworkers, and I made some progress on my Star Trek Game (Which has kinda been stuck in development hell for the last two years).

Unlike some of my previous code that I have written, coming back to Trekwars (second rewrite I might add) was very pleasant, good planning and Object Oriented Design seems to have paid off :)

I was able to implement the tick/turn system, and did some GUI work on the galaxy view, and halfway implemented the system view and research view. I also worked a bit on the order system, so given a few more hours of development I think I could actually move fleets of ships around :D

Still much work to be done until the game is anywhere near playable

  • Starship pathing algorithm and order system
  • Server data limiting (The client receives a big map ‘the galaxy’ from the server, currently it sends EVERYTHING, but this will have to be changed so that users cant cheat by reading “secret” data. Also by making a custom user copy the server will enable fog of war, and “distort” information in far away areas where sensor strength/resolution is low)
  • Sensor coverage algorithm (got it worked out on paper somewhere)
  • Planet Build systems (halfway done)
  • Combat resolution (ship to ship + ground combat)
  • Colonization and Starbases + Listening posts construction
  • Social tools (ingame mail + chat)
  • Natural phenomena (black holes, neutron stars, nebula, wormholes, etc..)

It was really fun working on the game again, and hopefully I wont shelve it for so long again. Here are some screenshots showing the GUI stuff done this weekend.

Galaxy view – shows the map with systems and starships
Trekwar galaxy

Star system map – Shows details about a star system, panel to build new structures/ships is not implemented yet. BTW those are temporary planet pictures that I drew in ms paint with my laptop touchpad this weekend, I actually think they are kind of cute :)
Trekwar system

Research View – Only just started this, so it just show your current research tree err.. stack :)
Trekwar research

using a large JLabel in a JScrollPane

Thursday, August 23rd, 2007

I was updating the SendSMS program I wrote, and instead of a JTable I wanted the list of messages sent to display in a better looking and more intuitive way. I decided to just use a JLabel and use html for displaying the sent messages:

JLabel using html in JScrollPane

I had the JLabel in a JPanel with GridLayout(1,1), and the Panel inside the JScrollPane. The JScrollPane always have vertical but never horizontal scrollbars.
The following problem arose: When the message got to long, it would not wrap, and end of message would disappear to the right.
The solution is simple: set the Width of the JPanel with the label to be roughly the size of the application window..

That did the trick, now however the scrollbar never updates when the Label gets very tall.

Apparently you cant just set just width for the Panel, you also have to set height.. again the solution is simple, set the height of the panel to be the height of the JLabel.

However since the JLabel is inside the JScrollPane (at least, I think that is the cause) the getSize and getPrefferedSize will return only the visible height of the JLabel. It took some playing around with but finally got it working by using the getMaximumSize.. NOTE: dont use the width from getMaximumSize() cause it is ridiculously large :)

the code:

historyPanel.setPreferredSize(new Dimension(historyScrollPane.getViewport().getSize().width, historyLabel.getMaximumSize().height));

Now I just have to find out if that way of getting the components height works the same across different platforms :)