
A Weather Applet Using HTTP
http://fivedots.coe.psu.ac.th/~ad/libgdx/

Andrew Davison, Jan. 2023
ad@fivedots.coe.psu.ac.th


Download gdx-setup.jar from 
https://libgdx.com/wiki/start/project-generation

When you run it, create code for 'Desktop' *and* 'HTML' platforms.
In what follows, I'll assume the Project Name was changed to 'weather', 
the package name was left unchanged as 'com.mygdx.game', and the
game class string was set to 'WeatherApp'.

In this zip file there are 3 folders:

  code/   
  assets/  
  launchers/

and the file:

  WeatherApp.gwt.xml
   -- this should be copied to weather\core\src,
      overwriting the file that's there already

-----------------------------
In code/:

 * Condition.java
 * Current.java
 * Error.java
 * Location.java
 * Weather.java
 * WeatherApp.java
 * WeatherError.java

Copy all of these to weather\core\src\com\mygdx\game
replacing the MyGdxGame.java file that's there
already.

Please note that I have replaced the Weather API key in
WeatherApp.java with a dummy string, "xxxx", assigned to
the API_KEY constant. This is NOT a real API key. 

You will need to register at https://www.weatherapi.com/ 
to get a key.

-----------------------------
In assets/:

 * data/
 * glassy/

Copy all of these to weather\assets
The badlogic.jpg file that's there already can be deleted.

-----------------------------
In launchers/:

 * DesktopLauncher.java
 * HtmlLauncher.java

Use these files to overwrite the existing files: 
  weather\desktop\src\com\mygdx\game\DesktopLauncher.java
and
  weather\html\src\com\mygdx\game\client\HtmlLauncher.java


------------------------------------
Compilation, Execution, Installation

Open a command line prompt in weather\, where
you will find a Windows batch script (gradlew.bat)
and a Bash script (gradlew).

There are three commands you need:

gradlew desktop:run

gradlew html:superdev

gradlew html:dist


Stage 1
-------
Use "gradlew desktop:run" to generate and run the desktop version. 
Compilation is quick, and you should use this version during 
program development.

Stage 2
-------
Use "gradlew html:superdev" to generate the HTML version which is
run via a local jetty-based HTML server. Access the page by typing

http://localhost:8080

into your browser. On my test machine, html:superdev takes about
30 seconds to complete.

Stage 3
-------
Use "gradlew html:dist" to generate the distribution code for uploading
to a real web server. On my test machine, this command takes about
40 seconds to finish, not including the time to move the files over to 
the server.

The code is generated in the folder weather\html\build\dist\

Copy everything over to your website:  
 * WEB-INF/
 * index.html
 * assets/
 * html/
 * styles.css

I placed all of these files in a new folder called weather\

I embedded a call to WeatherApp's index.html in an iframe in: 
http://fivedots.coe.psu.ac.th/~ad/libgdx/index.html

The iframe code is:

<p align="center">
<iframe src="http://fivedots.coe.psu.ac.th/~ad/libgdx/weather/index.html" 
        width="800px" height="600px">
</iframe>
<p>

