Skip to content

Commit

Permalink
Add Help command and finetune GUI
Browse files Browse the repository at this point in the history
Adding a help command allows inexperienced users to find a list of
commands that can be used.

Let's,
 * Add help command functionality.
 * Update checkstyle.
 * Add SVG icon and title to GUI title bar.
macareonie committed Feb 17, 2024
1 parent aa259ec commit 1e0bcb4
Showing 6 changed files with 41 additions and 12 deletions.
6 changes: 6 additions & 0 deletions src/main/java/tsundere/Main.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package tsundere;

import java.io.IOException;
import java.util.Objects;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;
import tsundere.gui.MainWindow;
@@ -22,6 +24,10 @@ public class Main extends Application {
@Override
public void start(Stage stage) {
try {
stage.setTitle("Tsundere Task Assistant");
stage.getIcons().add(new Image(Objects.requireNonNull(getClass()
.getResourceAsStream("/images/chitoge2.png"))));

FXMLLoader fxmlLoader = new FXMLLoader(Main.class.getResource("/view/MainWindow.fxml"));
AnchorPane ap = fxmlLoader.load();
Scene scene = new Scene(ap);
37 changes: 29 additions & 8 deletions src/main/java/tsundere/task/TaskList.java
Original file line number Diff line number Diff line change
@@ -25,15 +25,15 @@ public class TaskList {
public static String unmarkTask() throws GeneralException {

if (TaskList.taskList.isEmpty()) {
throw new GeneralException("What you tryna unmark huh?");
throw new GeneralException("There's nothing to unmark here");
}
try {
Task t = TaskList.taskList.get(Integer.parseInt(Parser.getName().substring(7, 8)) - 1);
if (t.getStatusIcon().equals(" ")) {
return "You haven't even started this task dummy!";
} else {
t.unMarkTask();
return t.toString();
return getListSize("unmarked", t);
}
} catch (NumberFormatException e) {
throw new GeneralException("Can't you even remember the proper format for this?\n"
@@ -53,15 +53,15 @@ public static String unmarkTask() throws GeneralException {
public static String markTask() throws GeneralException {

if (TaskList.taskList.isEmpty()) {
throw new GeneralException("What you tryna mark huh?");
throw new GeneralException("There's nothing to mark here!");
}
try {
Task t = TaskList.taskList.get(Integer.parseInt(Parser.getName().substring(5, 6)) - 1);
if (t.isDone) {
return "You already finished this!";
return "You already marked this!";
} else {
t.markTaskAsDone();
return t.toString();
return getListSize("marked", t);
}
} catch (NumberFormatException e) {
throw new GeneralException("Can't you even remember the proper format for this?\n"
@@ -81,7 +81,7 @@ public static String markTask() throws GeneralException {
public static String deleteTask() throws GeneralException {

if (TaskList.taskList.isEmpty()) {
throw new GeneralException("What you tryna delete huh?");
throw new GeneralException("There's nothing to delete here!");
}

try {
@@ -271,15 +271,15 @@ public static String untagTask() throws GeneralException {
}

/**
* Prints number of Tasks in TaskList.
* Returns number of Tasks in TaskList.
*
* @return String containing number of Tasks left if any in the TaskList.
*/
public static String getListSize(String str, Task t) {
String response = "";
int size = TaskList.taskList.size();
response += "Noted...";
response += " " + t.toString() + " has been " + str + "\n";
response += " " + t.toString() + " has been " + str + ".\n";

if (size > 0) {
response += "Get to work! You still have " + size + " " + (size > 1 ? "tasks" : "task") + " left!";
@@ -289,4 +289,25 @@ public static String getListSize(String str, Task t) {
return response;

}

/**
* Returns a list of all possible command.
*
* @return String containing all the command formats.
*/
public static String listCommands() {
return "It's merely a coincidence I have the list of commands here...\n"
+ "1. todo [task]\n"
+ "2. event [task], from [ ], to [ ]\n"
+ "3. deadline [task], by [yyyy-mm-dd]\n"
+ "4. find [keyword]\n"
+ "5. list\n"
+ "6. mark [task no.]\n"
+ "7. unmark [task no.]\n"
+ "8. delete [task no.]\n"
+ "9. tag [task no.] [tagname]\n"
+ "10. untag [task no.] [tagname]\n"
+ "11. help\n"
+ "12. bye";
}
}
4 changes: 3 additions & 1 deletion src/main/java/tsundere/ui/Parser.java
Original file line number Diff line number Diff line change
@@ -44,8 +44,10 @@ public String execute() throws GeneralException {
return TaskList.untagTask();
} else if (name.contains("tag")) {
return TaskList.tagTask();
} else if (name.contains("help")) {
return TaskList.listCommands();
} else {
return ("Don't talk to me!\nGive me proper instructions!");
return "Don't talk to me!\nGive me proper instructions!\n Hint: type \"help\"";
}

}
Binary file added src/main/resources/images/chitoge2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed src/main/resources/images/npc.png
Binary file not shown.
6 changes: 3 additions & 3 deletions src/main/resources/view/DialogBox.fxml
Original file line number Diff line number Diff line change
@@ -8,8 +8,8 @@
<?import javafx.scene.text.Font?>
<?import javafx.scene.layout.StackPane?>

<!-- Referenced and adapted dialog from @rehad-a-->
<fx:root style="" alignment="TOP_RIGHT" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefWidth="400.0" type="javafx.scene.layout.HBox" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1">
<!-- Solution below adapted from @rehad-a namely the addition of HBox.margin and padding-->
<fx:root style="-fx-font-weight: bold" alignment="TOP_RIGHT" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefWidth="400.0" type="javafx.scene.layout.HBox" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1">
<children>
<Label fx:id="dialog" minHeight="-Infinity" lineSpacing="1.0" style="-fx-background-color: #50f283; -fx-background-radius: 15; -fx-label-padding: 1;" text="Label" wrapText="true">
<padding>
@@ -19,7 +19,7 @@
<Insets />
</HBox.margin>
<font>
<Font name="System Bold" size="12.0" />
<Font name="Montserrat Bold" size="12.0" />
</font>
</Label>
<StackPane>

0 comments on commit 1e0bcb4

Please sign in to comment.