Skip to content

Commit e5a6ccb

Browse files
authored
Merge pull request #629 from neph1/add_game_template
Add game template
2 parents ae2a1eb + 992282f commit e5a6ccb

32 files changed

+3640
-1
lines changed

jme3-templates/src/com/jme3/gde/templates/Bundle.properties

+4-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,7 @@ OpenIDE-Module-Long-Description=\
55
OpenIDE-Module-Name=Project Templates
66
OpenIDE-Module-Short-Description=Provides Project Templates
77
Templates/Project/JME3/BasicGameProject.zip=Basic Game (with Ant)
8-
Templates/Project/JME3/GradleDesktopGameProject.zip=Basic Game (with Gradle)
8+
Templates/Project/JME3/GradleDesktopGameProject.zip=Basic Game (with Gradle)
9+
Templates/Project/JME3/Examples/RollingTheMonkeyProject.zip=Rolling The Monkey
10+
Templates/Project/JME3/Examples/MonkeyZone=Monkey Zone
11+
Templates/Project/JME3/Examples/JaimesAscent=Jaimes Ascent
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
LBL_DownloadProjectStep=Download project
2+
LBL_CreateProjectStep=Name and Location
3+
JaimesAscentPanelVisual.browseButton.text=Br&owse...
4+
JaimesAscentPanelVisual.createdFolderLabel.text=Project &Folder:
5+
JaimesAscentPanelVisual.projectLocationLabel.text=Project &Location:
6+
JaimesAscentDownloadPanelVisual.downloadButton.text=Download project
7+
JaimesAscentDownloadPanelVisual.downloadButton.actionCommand=DOWNLOAD
8+
JaimesAscentPanelVisual.projectNameLabel.text=Project &Name:
9+
JaimesAscentPanelVisual.browseButton.text=Browse
10+
JaimesAscentPanelVisual.browseButton.actionCommand=BROWSE
11+
JaimesAscentDownloadPanelVisual.jTextArea1.text=Pressing the button below will download the project from Github, to a temporary location from which it will be installed in the next step\n
12+
JaimesAscentDownloadPanelVisual.statusField.text=
13+
JaimesAscentDownloadPanelVisual.downloading=Downloading... Please wait
14+
JaimesAscentDownloadPanelVisual.downloadSuccess=Download complete. Press 'next' to proceed.
15+
JaimesAscentDownloadPanelVisual.downloadFailed=Download failed.
16+
JaimesAscentDownloadPanelVisual.jLabel1.text=
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<html>
2+
<head>
3+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4+
<title>Jaimes Ascent</title>
5+
</head>
6+
<body>
7+
A sample application demonstrating a chase cam with mouse look,<br>
8+
physics, moving objects and animations.
9+
10+
Easily extendable classes and architecture using AppStates and Controls.<br>
11+
Suitable for beginners.<br>
12+
</body>
13+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
/*
2+
* Copyright (c) 2024 jMonkeyEngine
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions are
7+
* met:
8+
*
9+
* * Redistributions of source code must retain the above copyright
10+
* notice, this list of conditions and the following disclaimer.
11+
*
12+
* * Redistributions in binary form must reproduce the above copyright
13+
* notice, this list of conditions and the following disclaimer in the
14+
* documentation and/or other materials provided with the distribution.
15+
*
16+
* * Neither the name of 'jMonkeyEngine' nor the names of its contributors
17+
* may be used to endorse or promote products derived from this software
18+
* without specific prior written permission.
19+
*
20+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22+
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24+
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27+
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28+
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29+
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31+
*/
32+
package com.jme3.gde.templates.jaimesascent;
33+
34+
import java.awt.Component;
35+
import java.io.BufferedInputStream;
36+
import java.io.File;
37+
import java.io.FileOutputStream;
38+
import java.io.IOException;
39+
import java.net.HttpURLConnection;
40+
import java.net.URL;
41+
import java.util.HashSet;
42+
import java.util.Set;
43+
import javax.swing.event.ChangeEvent;
44+
import javax.swing.event.ChangeListener;
45+
import org.openide.WizardDescriptor;
46+
import org.openide.WizardValidationException;
47+
import org.openide.util.HelpCtx;
48+
import org.openide.util.NbBundle;
49+
50+
/**
51+
* Panel just asking for basic info.
52+
*/
53+
@SuppressWarnings({"unchecked", "rawtypes"})
54+
public class JaimesAscentDownloadPanel implements WizardDescriptor.Panel,
55+
WizardDescriptor.ValidatingPanel, WizardDescriptor.FinishablePanel {
56+
57+
private WizardDescriptor wizardDescriptor;
58+
private JaimesAscentDownloadPanelVisual component;
59+
60+
static String ZIP_NAME = "JaimesAscent.zip";
61+
static String DOWNLOAD_FOLDER = System.getProperty("java.io.tmpdir");
62+
63+
public JaimesAscentDownloadPanel() {
64+
}
65+
66+
public int doDownloadZip() {
67+
return downloadFile("https://github.com/neph1/JaimesAscent/archive/refs/tags/v1.1.1.zip", DOWNLOAD_FOLDER, ZIP_NAME);
68+
}
69+
70+
private int downloadFile(String fileURL, String saveDir, String fileName) {
71+
HttpURLConnection httpConn = null;
72+
BufferedInputStream inputStream = null;
73+
FileOutputStream fileOutputStream = null;
74+
75+
final File outputFile = new File(saveDir, fileName);
76+
77+
if (outputFile.exists()) {
78+
return 1;
79+
}
80+
81+
try {
82+
// Create URL object
83+
URL url = new URL(fileURL);
84+
httpConn = (HttpURLConnection) url.openConnection();
85+
86+
// Check HTTP response code
87+
int responseCode = httpConn.getResponseCode();
88+
if (responseCode == HttpURLConnection.HTTP_OK) {
89+
// Open input stream from the HTTP connection
90+
inputStream = new BufferedInputStream(httpConn.getInputStream());
91+
92+
93+
94+
// Create output stream to save the file
95+
fileOutputStream = new FileOutputStream(outputFile);
96+
97+
byte[] buffer = new byte[4096];
98+
int bytesRead;
99+
while ((bytesRead = inputStream.read(buffer)) != -1) {
100+
fileOutputStream.write(buffer, 0, bytesRead);
101+
}
102+
103+
return 1;
104+
}
105+
} catch (IOException e) {
106+
return 0;
107+
} finally {
108+
// Close resources
109+
try {
110+
if (inputStream != null) inputStream.close();
111+
if (fileOutputStream != null) fileOutputStream.close();
112+
if (httpConn != null) httpConn.disconnect();
113+
} catch (IOException ex) {
114+
return 0;
115+
}
116+
}
117+
return 0;
118+
}
119+
120+
@Override
121+
public Component getComponent() {
122+
if (component == null) {
123+
component = new JaimesAscentDownloadPanelVisual(this);
124+
component.setName(NbBundle.getMessage(JaimesAscentDownloadPanel.class, "LBL_DownloadProjectStep"));
125+
}
126+
return component;
127+
}
128+
129+
@Override
130+
public HelpCtx getHelp() {
131+
return new HelpCtx("sdk.download_project");
132+
}
133+
134+
@Override
135+
public boolean isValid() {
136+
getComponent();
137+
return component.valid(wizardDescriptor);
138+
}
139+
140+
private final Set<ChangeListener> listeners = new HashSet<>(1); // or can use ChangeSupport in NB 6.0
141+
142+
@Override
143+
public final void addChangeListener(ChangeListener l) {
144+
synchronized (listeners) {
145+
listeners.add(l);
146+
}
147+
}
148+
149+
@Override
150+
public final void removeChangeListener(ChangeListener l) {
151+
synchronized (listeners) {
152+
listeners.remove(l);
153+
}
154+
}
155+
156+
protected final void fireChangeEvent() {
157+
Set<ChangeListener> ls;
158+
synchronized (listeners) {
159+
ls = new HashSet<>(listeners);
160+
}
161+
ChangeEvent ev = new ChangeEvent(this);
162+
for (ChangeListener l : ls) {
163+
l.stateChanged(ev);
164+
}
165+
}
166+
167+
@Override
168+
public void readSettings(Object settings) {
169+
wizardDescriptor = (WizardDescriptor) settings;
170+
component.read(wizardDescriptor);
171+
}
172+
173+
@Override
174+
public void storeSettings(Object settings) {
175+
WizardDescriptor d = (WizardDescriptor) settings;
176+
component.store(d);
177+
}
178+
179+
@Override
180+
public boolean isFinishPanel() {
181+
return false;
182+
}
183+
184+
@Override
185+
public void validate() throws WizardValidationException {
186+
getComponent();
187+
component.validate(wizardDescriptor);
188+
}
189+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
3+
<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
4+
<AuxValues>
5+
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
6+
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
7+
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
8+
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
9+
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
10+
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
11+
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
12+
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
13+
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="0"/>
14+
</AuxValues>
15+
16+
<Layout>
17+
<DimensionLayout dim="0">
18+
<Group type="103" groupAlignment="0" attributes="0">
19+
<Group type="102" alignment="0" attributes="0">
20+
<EmptySpace max="-2" attributes="0"/>
21+
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
22+
<Group type="103" groupAlignment="0" attributes="0">
23+
<Group type="102" attributes="0">
24+
<EmptySpace max="-2" attributes="0"/>
25+
<Group type="103" groupAlignment="0" attributes="0">
26+
<Component id="jScrollPane1" alignment="0" min="-2" pref="307" max="-2" attributes="0"/>
27+
<Component id="statusField" alignment="1" min="-2" pref="313" max="-2" attributes="0"/>
28+
</Group>
29+
</Group>
30+
<Group type="102" alignment="0" attributes="0">
31+
<EmptySpace min="-2" pref="99" max="-2" attributes="0"/>
32+
<Component id="downloadButton" min="-2" max="-2" attributes="0"/>
33+
</Group>
34+
</Group>
35+
<EmptySpace max="32767" attributes="0"/>
36+
</Group>
37+
</Group>
38+
</DimensionLayout>
39+
<DimensionLayout dim="1">
40+
<Group type="103" groupAlignment="0" attributes="0">
41+
<Group type="102" attributes="0">
42+
<Group type="103" groupAlignment="0" attributes="0">
43+
<Group type="102" alignment="0" attributes="0">
44+
<EmptySpace min="-2" pref="71" max="-2" attributes="0"/>
45+
<Component id="jScrollPane1" min="-2" max="-2" attributes="0"/>
46+
<EmptySpace min="-2" pref="21" max="-2" attributes="0"/>
47+
<Component id="downloadButton" min="-2" max="-2" attributes="0"/>
48+
<EmptySpace type="separate" max="-2" attributes="0"/>
49+
<Component id="statusField" min="-2" pref="52" max="-2" attributes="0"/>
50+
</Group>
51+
<Group type="102" alignment="0" attributes="0">
52+
<EmptySpace max="-2" attributes="0"/>
53+
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
54+
</Group>
55+
</Group>
56+
<EmptySpace max="32767" attributes="0"/>
57+
</Group>
58+
</Group>
59+
</DimensionLayout>
60+
</Layout>
61+
<SubComponents>
62+
<Component class="javax.swing.JButton" name="downloadButton">
63+
<Properties>
64+
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
65+
<ResourceString bundle="com/jme3/gde/templates/monkeyzone/Bundle.properties" key="JaimesAscentDownloadPanelVisual.downloadButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
66+
</Property>
67+
<Property name="actionCommand" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
68+
<ResourceString bundle="com/jme3/gde/templates/monkeyzone/Bundle.properties" key="JaimesAscentDownloadPanelVisual.downloadButton.actionCommand" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
69+
</Property>
70+
</Properties>
71+
<Events>
72+
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="downloadButtonActionPerformed"/>
73+
</Events>
74+
</Component>
75+
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
76+
<AuxValues>
77+
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
78+
</AuxValues>
79+
80+
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
81+
<SubComponents>
82+
<Component class="javax.swing.JTextArea" name="jTextArea1">
83+
<Properties>
84+
<Property name="editable" type="boolean" value="false"/>
85+
<Property name="columns" type="int" value="20"/>
86+
<Property name="lineWrap" type="boolean" value="true"/>
87+
<Property name="rows" type="int" value="5"/>
88+
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
89+
<ResourceString bundle="com/jme3/gde/templates/monkeyzone/Bundle.properties" key="JaimesAscentDownloadPanelVisual.jTextArea1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
90+
</Property>
91+
<Property name="wrapStyleWord" type="boolean" value="true"/>
92+
<Property name="enabled" type="boolean" value="false"/>
93+
</Properties>
94+
</Component>
95+
</SubComponents>
96+
</Container>
97+
<Component class="javax.swing.JTextField" name="statusField">
98+
<Properties>
99+
<Property name="editable" type="boolean" value="false"/>
100+
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
101+
<ResourceString bundle="com/jme3/gde/templates/monkeyzone/Bundle.properties" key="JaimesAscentDownloadPanelVisual.statusField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
102+
</Property>
103+
<Property name="enabled" type="boolean" value="false"/>
104+
</Properties>
105+
<Events>
106+
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="statusFieldActionPerformed"/>
107+
</Events>
108+
</Component>
109+
<Component class="javax.swing.JLabel" name="jLabel1">
110+
<Properties>
111+
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
112+
<Image iconType="3" name="/com/jme3/gde/templates/jaimesascent/jaimesascent.png"/>
113+
</Property>
114+
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
115+
<ResourceString bundle="com/jme3/gde/templates/monkeyzone/Bundle.properties" key="JaimesAscentDownloadPanelVisual.jLabel1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
116+
</Property>
117+
</Properties>
118+
</Component>
119+
</SubComponents>
120+
</Form>

0 commit comments

Comments
 (0)