Skip to content

Commit b9d8039

Browse files
authored
Merge pull request #6 from netrek/development
Version-1.0.0
2 parents 05ce9f3 + 02385c6 commit b9d8039

File tree

11 files changed

+112
-79
lines changed

11 files changed

+112
-79
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,6 @@
2121

2222
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
2323
hs_err_pid*
24+
25+
# not sure about this
26+
bin/

LICENSE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ package jtrek;
134134
* Inc.
135135
*/
136136
public interface Copyright {
137-
String VERSION = "JTrek version 0.9.7 Beta";
137+
String VERSION = "JTrek version 1.0.0";
138138

139139
String[] AUTHORS = {
140140
"Robert Temple","Darrell Root"

README.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
README for version 0.9.7 Beta by Darrell Root
1+
README for version 1.0.0 by Darrell Root
22

33
I've taken Robert Temple's old JTrek code from 1998 and am attempting to update
44
it to run on recent versions of Java. Most of the code is cut-and-pasted from
55
Robert's source code.
66

7+
1.0.0: Fixed a bunch of bugs around resizing
8+
0.9.7: sound and resizing
79
0.9.6 update: multi-button mouse works! But we have high cpu utilization and need profiling.
810

911
Long live Netrek! - Darrell [email protected]

src/jtrek/input/KeyInputHandler.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ public void handleKey(int key) {
329329
break;
330330
case 'h':
331331
// h = Map help window
332+
view.help.setBounds(100, 100, 700, 400);
332333
view.help.setVisible(!view.help.isVisible());
333334
break;
334335
case 'w':

src/jtrek/visual/EntryPanel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public void redraw() {
6868
public void paint(Graphics g) {
6969
g.setFont(big_font);
7070
g.setColor(Color.white);
71-
int y = g.getFontMetrics().getHeight() + 1;
71+
int y = g.getFontMetrics().getHeight() + 30;
7272
g.drawString(VERSION + " by " + AUTHORS[0], 20, y);
7373
g.setFont(variable_font);
7474
y += g.getFontMetrics().getHeight() + 3;

src/jtrek/visual/HelpPanel.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,13 @@ public void update(Graphics g) {
104104
int x = 8;
105105

106106
for(int i = 0, column = 0; column < 3 && i < help_message.length; ++column) {
107-
int y = row_height + 6;
107+
int y = row_height + 26;
108108
for(int row = 0; row < help_message.length / 3 && i < help_message.length; ++row, ++i) {
109109
g.drawString(updateKeyToKeymap(help_message[i]), x, y);
110110
y += row_height;
111111
}
112112
x += column_width;
113-
}
113+
}
114114
}
115115

116116
String updateKeyToKeymap(String message) {

src/jtrek/visual/InfoPanel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public void update(Graphics g) {
7474
g.setFont(fixed_font);
7575
g.setColor(Color.white);
7676
int line_height = g.getFontMetrics().getHeight();
77-
int y = 3;
77+
int y = view_size.height / 10;
7878
int bottom = (position + visible < extent) ? position + visible : extent;
7979
for(int l = position; l < bottom; ++l) {
8080
g.drawString(lines[l], 12, y += line_height);

src/jtrek/visual/LocalPanel.java

Lines changed: 45 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,13 @@ public void newShip() {
6666
* That's 20% across the universe.
6767
*/
6868
private void recalculateScale() {
69-
int viewWidth = this.getWidth();
69+
int viewWidth = Math.min(this.getWidth(),this.getHeight());
7070
if (viewWidth < 100) {
7171
// giving up, view too small
7272
return;
7373
}
7474
LocalPanel.VIEW = TARGET_VIEW_WIDTH / 2;
75-
LocalPanel.SCALE = TARGET_VIEW_WIDTH / viewWidth;
75+
LocalPanel.SCALE = (TARGET_VIEW_WIDTH - (2 * BORDER)) / viewWidth;
7676

7777
}
7878

@@ -113,47 +113,63 @@ public void update(Graphics g) {
113113
int dx, dy, sx, sy, source_y;
114114
Player me = data.me;
115115

116-
// Change border color to signify alert status
117-
if (alert != (me.flags & ALERT_FILTER)) {
118-
alert = (me.flags & ALERT_FILTER);
119-
switch (alert) {
120-
case Player.GREEN :
121-
view.sound_player.abortSound(SoundPlayer.WARNING_SOUND);
122-
border_color = Color.green;
123-
break;
124-
case Player.YELLOW :
125-
view.sound_player.abortSound(SoundPlayer.WARNING_SOUND);
126-
border_color = Color.yellow;
127-
break;
128-
case Player.RED :
129-
view.sound_player.playSound(SoundPlayer.WARNING_SOUND);
130-
border_color = Color.red;
131-
break;
132-
}
133-
paintBorder(g);
116+
117+
// move bitmap at speed 2 if orbiting
118+
if ((me.flags & Player.ORBIT) != 0) {
119+
background_x -= Trigonometry.COS[me.dir] * 2f * 20f / SCALE;
120+
background_y -= Trigonometry.SIN[me.dir] * 2f * 20f / SCALE;
134121
}
122+
123+
// background_x -= Trigonometry.COS[me.dir] * (float)me.speed / 4f;
124+
//background_x -= Trigonometry.COS[me.dir] * (float)me.speed * SCALE / 80f;
125+
background_x -= Trigonometry.COS[me.dir] * (float)me.speed * 20f / SCALE ;
135126

136-
background_x -= Trigonometry.COS[me.dir] * (float)me.speed / 4f;
137127
if(background_x < -bitmaps.background_width) {
138128
background_x += bitmaps.background_width;
139129
}
140130
else if(background_x > 0.0f) {
141131
background_x -= bitmaps.background_width;
142132
}
143133

144-
background_y -= Trigonometry.SIN[me.dir] * (float)me.speed / 4f;
134+
// background_y -= Trigonometry.SIN[me.dir] * (float)me.speed / 4f;
135+
//background_y -= Trigonometry.SIN[me.dir] * (float)me.speed * SCALE / 80f;
136+
background_y -= Trigonometry.SIN[me.dir] * (float)me.speed * 20f / SCALE;
137+
145138
if(background_y < -bitmaps.background_height) {
146139
background_y += bitmaps.background_height;
147140
}
148141
else if(background_y > 0.0f) {
149142
background_y -= bitmaps.background_height;
150143
}
144+
151145

152146
for(int y = (int)background_y; y < view_size.height; y += bitmaps.background_height) {
153147
for(int x = (int)background_x; x < view_size.width; x += bitmaps.background_width) {
154148
og.drawImage(bitmaps.background, x, y, Color.black, null);
155149
}
156150
}
151+
152+
// Change border color to signify alert status
153+
if (alert != (me.flags & ALERT_FILTER)) {
154+
alert = (me.flags & ALERT_FILTER);
155+
switch (alert) {
156+
case Player.GREEN :
157+
view.sound_player.abortSound(SoundPlayer.WARNING_SOUND);
158+
border_color = Color.green;
159+
break;
160+
case Player.YELLOW :
161+
view.sound_player.abortSound(SoundPlayer.WARNING_SOUND);
162+
border_color = Color.yellow;
163+
break;
164+
case Player.RED :
165+
view.sound_player.playSound(SoundPlayer.WARNING_SOUND);
166+
border_color = Color.red;
167+
break;
168+
}
169+
paintBorder(g);
170+
}
171+
172+
157173

158174
jtrek.util.Rectangle bounds = new jtrek.util.Rectangle(
159175
me.x - VIEW, me.y - VIEW, me.x - VIEW + 20000, me.y - VIEW + 20000);
@@ -162,7 +178,7 @@ else if(background_y > 0.0f) {
162178

163179
// draw the edges of the galaxy
164180
og.setColor(Color.red);
165-
og.drawRect(0, 0, 2500, 2500);
181+
og.drawRect(0, 0, 100000 / SCALE, 100000 / SCALE);
166182

167183
// draw out the planets
168184
for(int p = data.planets.length; --p >= 0;) {
@@ -193,10 +209,11 @@ else if((planet.flags & Planet.AGRI) != 0) {
193209
//no longer cycling fancy planet graphics - Darrell 0.9.7
194210
//og.drawImage(planet_image, dx, dy, dx + 30, dy + 30, 0, source_y, 30, source_y + 30, null);
195211

212+
int planetSize = 1200 / SCALE; // used to be 30
196213
if ((planet.info & me.team.bit) != 0) {
197214
switch(Defaults.show_local) {
198215
case 0 :
199-
og.drawImage(bitmaps.teams, dx, dy, dx + 30, dy + 30, 0, planet.owner.no * 30, 30, planet.owner.no * 30 + 30, null);
216+
og.drawImage(bitmaps.teams, dx, dy, dx + planetSize, dy + planetSize, 0, planet.owner.no * 30, 30, planet.owner.no * 30 + 30, null);
200217
break;
201218
case 1 :
202219
int planet_type = (planet.armies > 4) ? 4 : 0;
@@ -206,7 +223,7 @@ else if((planet.flags & Planet.AGRI) != 0) {
206223
if ((planet.flags & Planet.FUEL) != 0) {
207224
planet_type += 1;
208225
}
209-
og.drawImage(bitmaps.resources, dx, dy, dx + 30, dy + 30, 0, planet_type * 30, 30, planet_type * 30 + 30, null);
226+
og.drawImage(bitmaps.resources, dx, dy, dx + planetSize, dy + planetSize, 0, planet_type * 30, 30, planet_type * 30 + 30, null);
210227
break;
211228
default :
212229
break;
@@ -218,7 +235,7 @@ else if((planet.flags & Planet.AGRI) != 0) {
218235
}
219236

220237
// Now just drawing circle for the planet - Darrell 0.9.7
221-
og.drawOval(dx, dy, 30, 30);
238+
og.drawOval(dx, dy, planetSize, planetSize);
222239

223240

224241
// draw the name of the planet
@@ -228,7 +245,8 @@ else if((planet.flags & Planet.AGRI) != 0) {
228245
if(Defaults.name_mode == 1 && s.length() > 5) {
229246
s = s.substring(0, 5);
230247
}
231-
og.drawString(s, dx + 15 - og.getFontMetrics().stringWidth(s) / 2, dy + 38);
248+
//og.drawString(s, dx + 15 - og.getFontMetrics().stringWidth(s) / 2, dy + 38);
249+
og.drawString(s, dx + planetSize / 2 - og.getFontMetrics().stringWidth(s) / 2, dy + planetSize + planetSize/2); // y coordinate + 1.5 * planetSize
232250
}
233251
} // end draw planets
234252

src/jtrek/visual/LoginPanel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ public void update(Graphics g) {
158158
og.drawLine(8, line_height + 1, 8 + og.getFontMetrics().stringWidth(s), line_height + 1);
159159
}
160160
else {
161-
int y = 0;
161+
int y = view_size.height / 10;
162162
if(autologin_failure) {
163163
String s = "Automatic login failed";
164164
og.drawString(s, 8, (y += line_height));

src/jtrek/visual/NetrekFrame.java

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -258,24 +258,8 @@ void resizeWindows() {
258258
dashboard.setBounds(0, leftYPosition, halfWidth, 51);;
259259
leftYPosition += 51;
260260

261-
// reviews seem to overlap
262-
review.setBounds(0,leftYPosition, halfWidth, windowHeight / 4);
261+
player_list.setBounds(0, leftYPosition, halfWidth, windowHeight /4);
263262
leftYPosition += windowHeight / 4;
264-
265-
review_all.setBounds(0,leftYPosition, halfWidth, windowHeight / 8);
266-
leftYPosition += windowHeight / 8;
267-
268-
review_team.setBounds(0,leftYPosition, halfWidth, windowHeight / 8);
269-
leftYPosition += windowHeight / 8;
270-
271-
review_your.setBounds(0, leftYPosition, halfWidth, windowHeight / 8);
272-
leftYPosition += windowHeight / 8;
273-
274-
review_kill.setBounds(0, leftYPosition, halfWidth, windowHeight / 8);
275-
leftYPosition += windowHeight / 8;
276-
277-
review_phaser.setBounds(0, leftYPosition, halfWidth, windowHeight / 8);
278-
leftYPosition += windowHeight / 8;
279263

280264
// right column
281265

@@ -288,10 +272,29 @@ void resizeWindows() {
288272
message.setBounds(halfWidth, rightYPosition, windowWidth/2, windowHeight / 28);
289273
rightYPosition += windowHeight / 28;
290274

291-
player_list.setBounds(halfWidth, rightYPosition, windowWidth / 2, windowHeight /4);
292-
rightYPosition += windowHeight / 4;
275+
//review.setBounds(halfWidth,rightYPosition, halfWidth, windowHeight / 6);
276+
int reviewHeight = windowHeight - rightYPosition;
277+
review.setBounds(halfWidth,rightYPosition, halfWidth, reviewHeight);
278+
rightYPosition += reviewHeight;
279+
//rightYPosition += windowHeight / 6;
293280

281+
// The reviews below do not seem to work
282+
// even with review above is commented out
283+
review_all.setBounds(halfWidth,rightYPosition, halfWidth, windowHeight / 8);
284+
rightYPosition += windowHeight / 8;
294285

286+
review_team.setBounds(halfWidth,rightYPosition, halfWidth, windowHeight / 8);
287+
rightYPosition += windowHeight / 8;
288+
289+
review_your.setBounds(halfWidth, rightYPosition, halfWidth, windowHeight / 8);
290+
rightYPosition += windowHeight / 8;
291+
292+
review_kill.setBounds(halfWidth, rightYPosition, halfWidth, windowHeight / 8);
293+
rightYPosition += windowHeight / 8;
294+
295+
review_phaser.setBounds(halfWidth, rightYPosition, halfWidth, windowHeight / 8);
296+
rightYPosition += windowHeight / 8;
297+
295298

296299
}
297300

0 commit comments

Comments
 (0)