Skip to content

Commit

Permalink
Merge branch 'main' into per/bugFixes
Browse files Browse the repository at this point in the history
  • Loading branch information
einaskoi authored May 25, 2026
2 parents 3960dfa + c496c08 commit 0854405
Show file tree
Hide file tree
Showing 35 changed files with 367 additions and 664 deletions.
58 changes: 57 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@
</dependencies>

<build>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand All @@ -60,14 +65,65 @@
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.8</version>
<configuration>
<mainClass>edu.ntnu.idi.idatt2003.gruppe42.Millions</mainClass>
<mainClass>edu.ntnu.idi.idatt2003.gruppe42.Launcher</mainClass>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.12.0</version>
</plugin>

<!-- Fat JAR builder -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.5.0</version>
<executions>
<execution>
<phase>package</phase>
<goals><goal>shade</goal></goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>edu.ntnu.idi.idatt2003.gruppe42.Launcher</mainClass>
</transformer>
</transformers>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>

<!-- .dmg packager -->
<plugin>
<groupId>org.panteleyev</groupId>
<artifactId>jpackage-maven-plugin</artifactId>
<version>1.6.0</version>
<configuration>
<name>Millions</name>
<appVersion>1.0.0</appVersion>
<vendor>edu.ntnu.idi.idatt2003.gruppe42</vendor>
<input>target</input>
<destination>target/dist</destination>
<mainJar>Millions-1.0-SNAPSHOT.jar</mainJar>
<mainClass>edu.ntnu.idi.idatt2003.gruppe42.Launcher</mainClass>
<type>DMG</type>
<icon>src/main/resources/images/app_icon.icns</icon>
<javaOptions>
<option>-Dfile.encoding=UTF-8</option>
</javaOptions>
</configuration>
</plugin>
</plugins>
</build>

Expand Down
7 changes: 7 additions & 0 deletions src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Launcher.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package edu.ntnu.idi.idatt2003.gruppe42;

public class Launcher {
public static void main(String[] args) {
Millions.launch(Millions.class, args);
}
}
9 changes: 5 additions & 4 deletions src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Millions.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
import edu.ntnu.idi.idatt2003.gruppe42.model.Player;
import edu.ntnu.idi.idatt2003.gruppe42.view.views.DesktopView;
import edu.ntnu.idi.idatt2003.gruppe42.view.views.StartView;
import java.nio.file.Path;

import java.io.InputStream;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.stage.Stage;
Expand Down Expand Up @@ -63,16 +64,16 @@ public void start(final Stage stage) {
*
* @param username the player name
* @param difficulty selected game difficulty
* @param userSelectedPath path to stock data file
* @param stocksStream path to stock data file
* @param popupsController controller managing popups
*/
public void initGame(final String username, final Difficulty difficulty,
Path userSelectedPath, PopupsController popupsController) {
InputStream stocksStream, PopupsController popupsController) {
player = GameFactory.createPlayer(username, difficulty);
gameController = new GameController();

desktopViewController = new DesktopViewController(player, gameController,
userSelectedPath, popupsController);
stocksStream, popupsController);
desktopViewController.setOnGameOver(this::resetGame);
desktopView = desktopViewController.getDesktopView();
scene.setRoot(desktopView.getRoot());
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/edu/ntnu/idi/idatt2003/gruppe42/audio/Audio.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
public enum Audio {

// Sound effects
OPEN_APP("/Audio/open_app.wav", true),
CLOSE_APP("/Audio/close_app.wav", true),
CLOCK("/Audio/clock.wav", true),
OPEN_APP("/audio/open_app.wav", true),
CLOSE_APP("/audio/close_app.wav", true),
CLOCK("/audio/clock.wav", true),

// Background music
WORK_THEME("/Audio/work_theme.mp3", false),
WEEKEND_THEME("/Audio/weekend_theme.mp3", false);
WORK_THEME("/audio/work_theme.mp3", false),
WEEKEND_THEME("/audio/weekend_theme.mp3", false);

private final String path;
private final boolean isSfx;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ private AudioManager() {
}
}

// Keep background music volume in sync with master × 0.5 (bg is quieter)
// Keep background music volume in sync with master × 0.5 (bg should be quieter for UX)
masterVolume.addListener((obs, ov, nv) -> {
if (bgPlayer != null) {
bgPlayer.setVolume(nv.doubleValue() * 0.5);
Expand Down Expand Up @@ -82,7 +82,6 @@ public void playSfx(final Audio audio) {
Clip clip = AudioSystem.getClip();
clip.open(stream);

// Apply volume via MASTER_GAIN
if (clip.isControlSupported(FloatControl.Type.MASTER_GAIN)) {
FloatControl gain = (FloatControl) clip.getControl(FloatControl.Type.MASTER_GAIN);
float db = volumeToDb(volume);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
import edu.ntnu.idi.idatt2003.gruppe42.model.StockFileHandler;
import edu.ntnu.idi.idatt2003.gruppe42.model.exceptions.StockFileParseException;
import java.io.IOException;
import java.nio.file.Path;
import java.util.HashMap;
import java.io.InputStream;
import java.util.List;
import java.util.Map;

Expand All @@ -29,8 +28,8 @@ public final class MarketController implements AppController {
* @throws IOException if the file cannot be read
* @throws StockFileParseException if the file content is malformed
*/
public MarketController(Path path) throws IOException, StockFileParseException {
exchange = new Exchange(StockFileHandler.readFromFile(path));
public MarketController(InputStream stocksStream) throws IOException, StockFileParseException {
exchange = new Exchange(StockFileHandler.readFromFile(stocksStream));
for (Stock stock : exchange.getAllStocks()) {
stockControllers.put(stock.getSymbol(), new StockController(stock));
}
Expand Down
Loading

0 comments on commit 0854405

Please sign in to comment.