Skip to content

Commit bf994e5

Browse files
committed
Merge branch 'feature/create-challenge-dynamically' into develop
- Add challenges and completed challenges dynamically - Implement automated next challenge generation feature - Add basic challenge list - Improve class structure - Enhanced UI
2 parents 5f4b8fa + e7c8993 commit bf994e5

File tree

9 files changed

+470
-81
lines changed

9 files changed

+470
-81
lines changed
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.github.ilovegamecoding.intellijcodexp.form.CodeXPChallengeForm">
3+
<grid id="27dc6" binding="pChallenge" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
4+
<margin top="0" left="0" bottom="0" right="0"/>
5+
<constraints>
6+
<xy x="20" y="20" width="400" height="117"/>
7+
</constraints>
8+
<properties/>
9+
<border type="none"/>
10+
<children>
11+
<component id="24948" class="javax.swing.JLabel" binding="lblChallengeName">
12+
<constraints>
13+
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false">
14+
<preferred-size width="385" height="17"/>
15+
</grid>
16+
</constraints>
17+
<properties>
18+
<font name="Noto Sans SemiBold" size="14" style="0"/>
19+
<text value="Challenge Title"/>
20+
</properties>
21+
</component>
22+
<grid id="74276" layout-manager="GridBagLayout">
23+
<constraints>
24+
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="1" fill="1" indent="0" use-parent-layout="false"/>
25+
</constraints>
26+
<properties/>
27+
<border type="none"/>
28+
<children>
29+
<component id="ff2ca" class="javax.swing.JProgressBar" binding="pbChallengeProgress">
30+
<constraints>
31+
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
32+
<gridbag top="0" left="0" bottom="0" right="4" weightx="1.0" weighty="1.0"/>
33+
</constraints>
34+
<properties>
35+
<stringPainted value="false"/>
36+
</properties>
37+
</component>
38+
<grid id="e1ea5" layout-manager="GridBagLayout">
39+
<constraints>
40+
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
41+
<gridbag top="0" left="0" bottom="0" right="8" weightx="0.0" weighty="0.0"/>
42+
</constraints>
43+
<properties/>
44+
<border type="none"/>
45+
<children>
46+
<component id="4ea00" class="javax.swing.JLabel" binding="lblChallengeProgress">
47+
<constraints>
48+
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
49+
<gridbag weightx="0.0" weighty="0.0"/>
50+
</constraints>
51+
<properties>
52+
<font name="Noto Sans Medium" size="12" style="0"/>
53+
<horizontalAlignment value="4"/>
54+
<horizontalTextPosition value="0"/>
55+
<preferredSize width="32" height="20"/>
56+
<text value="100"/>
57+
</properties>
58+
</component>
59+
<component id="58862" class="javax.swing.JLabel" binding="lblChallengePercentageIcon">
60+
<constraints>
61+
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
62+
<gridbag top="0" left="4" bottom="0" right="0" weightx="0.0" weighty="0.0"/>
63+
</constraints>
64+
<properties>
65+
<font name="Noto Sans Medium" size="12" style="0"/>
66+
<horizontalAlignment value="2"/>
67+
<text resource-bundle="messages/CodeXPBundle" key="TEXT_%"/>
68+
</properties>
69+
</component>
70+
</children>
71+
</grid>
72+
</children>
73+
</grid>
74+
<grid id="37efc" layout-manager="GridBagLayout">
75+
<constraints>
76+
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
77+
<preferred-size width="385" height="24"/>
78+
</grid>
79+
</constraints>
80+
<properties/>
81+
<border type="none"/>
82+
<children>
83+
<component id="dffc2" class="javax.swing.JLabel" binding="lblChallengeDescription">
84+
<constraints>
85+
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
86+
<gridbag weightx="1.0" weighty="1.0"/>
87+
</constraints>
88+
<properties>
89+
<font name="Noto Sans Medium" size="12" style="0"/>
90+
<text value="This is a challenge description"/>
91+
</properties>
92+
</component>
93+
<grid id="5e072" layout-manager="GridBagLayout">
94+
<constraints>
95+
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="4" fill="2" indent="0" use-parent-layout="false"/>
96+
<gridbag weightx="0.0" weighty="0.0"/>
97+
</constraints>
98+
<properties/>
99+
<border type="none"/>
100+
<children>
101+
<component id="8f47b" class="javax.swing.JLabel">
102+
<constraints>
103+
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
104+
<gridbag weightx="0.0" weighty="0.0"/>
105+
</constraints>
106+
<properties>
107+
<text resource-bundle="messages/CodeXPBundle" key="TEXT_+"/>
108+
</properties>
109+
</component>
110+
<component id="3ed92" class="javax.swing.JLabel" binding="lblChallengeReward">
111+
<constraints>
112+
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
113+
<gridbag weightx="0.0" weighty="0.0"/>
114+
</constraints>
115+
<properties>
116+
<text value="100"/>
117+
</properties>
118+
</component>
119+
<component id="10c9f" class="javax.swing.JLabel">
120+
<constraints>
121+
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
122+
<gridbag top="0" left="4" bottom="0" right="0" weightx="0.0" weighty="0.0"/>
123+
</constraints>
124+
<properties>
125+
<text resource-bundle="messages/CodeXPBundle" key="TEXT_XP"/>
126+
</properties>
127+
</component>
128+
</children>
129+
</grid>
130+
</children>
131+
</grid>
132+
</children>
133+
</grid>
134+
</form>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.github.ilovegamecoding.intellijcodexp.form;
2+
3+
import javax.swing.*;
4+
5+
public class CodeXPChallengeForm {
6+
public String challengeID;
7+
public JProgressBar pbChallengeProgress;
8+
public JLabel lblChallengeDescription;
9+
public JLabel lblChallengeName;
10+
public JLabel lblChallengeProgress;
11+
public JLabel lblChallengeReward;
12+
public JPanel pChallenge;
13+
public JLabel lblChallengePercentageIcon;
14+
}

src/main/java/com/github/ilovegamecoding/intellijcodexp/form/CodeXPDashboard.form

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<grid id="27dc6" binding="pMain" layout-manager="GridLayoutManager" row-count="12" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
44
<margin top="0" left="0" bottom="0" right="0"/>
55
<constraints>
6-
<xy x="20" y="20" width="606" height="566"/>
6+
<xy x="20" y="20" width="606" height="614"/>
77
</constraints>
88
<properties/>
99
<border type="none"/>
@@ -166,7 +166,7 @@
166166
</children>
167167
</grid>
168168
<grid id="42abc" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
169-
<margin top="8" left="8" bottom="0" right="0"/>
169+
<margin top="16" left="8" bottom="0" right="0"/>
170170
<constraints>
171171
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="true"/>
172172
</constraints>
@@ -185,7 +185,7 @@
185185
</children>
186186
</grid>
187187
<grid id="a690a" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
188-
<margin top="8" left="8" bottom="0" right="0"/>
188+
<margin top="16" left="8" bottom="0" right="0"/>
189189
<constraints>
190190
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="true"/>
191191
</constraints>
@@ -204,7 +204,7 @@
204204
</children>
205205
</grid>
206206
<grid id="646d2" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
207-
<margin top="8" left="8" bottom="0" right="0"/>
207+
<margin top="16" left="8" bottom="0" right="0"/>
208208
<constraints>
209209
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="1" anchor="0" fill="3" indent="0" use-parent-layout="true"/>
210210
</constraints>
@@ -223,7 +223,7 @@
223223
</children>
224224
</grid>
225225
<grid id="5bee" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
226-
<margin top="8" left="8" bottom="0" right="0"/>
226+
<margin top="16" left="8" bottom="0" right="0"/>
227227
<constraints>
228228
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="true"/>
229229
</constraints>
@@ -242,7 +242,7 @@
242242
</children>
243243
</grid>
244244
<grid id="a16cf" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
245-
<margin top="8" left="16" bottom="0" right="8"/>
245+
<margin top="16" left="16" bottom="0" right="8"/>
246246
<constraints>
247247
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
248248
</constraints>
@@ -265,7 +265,7 @@
265265
</children>
266266
</grid>
267267
<grid id="382ad" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="4" vgap="-1">
268-
<margin top="8" left="0" bottom="0" right="0"/>
268+
<margin top="16" left="0" bottom="0" right="0"/>
269269
<constraints>
270270
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
271271
</constraints>
@@ -294,7 +294,7 @@
294294
</children>
295295
</grid>
296296
<grid id="b2d31" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="4" vgap="-1">
297-
<margin top="8" left="0" bottom="0" right="0"/>
297+
<margin top="16" left="0" bottom="0" right="0"/>
298298
<constraints>
299299
<grid row="4" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
300300
</constraints>
@@ -347,14 +347,14 @@
347347
<children/>
348348
</grid>
349349
<grid id="fb8a9" binding="lblCompletedChallenges" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
350-
<margin top="8" left="0" bottom="0" right="0"/>
350+
<margin top="16" left="0" bottom="0" right="0"/>
351351
<constraints>
352352
<grid row="9" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
353353
</constraints>
354354
<properties/>
355355
<border type="none"/>
356356
<children>
357-
<component id="bf652" class="javax.swing.JLabel">
357+
<component id="bf652" class="javax.swing.JLabel" binding="lblCompletedChallengesCount">
358358
<constraints>
359359
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
360360
</constraints>
@@ -367,7 +367,7 @@
367367
</children>
368368
</grid>
369369
<grid id="588b9" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
370-
<margin top="8" left="8" bottom="0" right="0"/>
370+
<margin top="16" left="8" bottom="0" right="0"/>
371371
<constraints>
372372
<grid row="7" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
373373
</constraints>
@@ -386,7 +386,7 @@
386386
</children>
387387
</grid>
388388
<grid id="906b2" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
389-
<margin top="8" left="8" bottom="0" right="0"/>
389+
<margin top="16" left="8" bottom="0" right="0"/>
390390
<constraints>
391391
<grid row="9" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="true"/>
392392
</constraints>

src/main/java/com/github/ilovegamecoding/intellijcodexp/form/CodeXPDashboard.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
package com.github.ilovegamecoding.intellijcodexp.form;
22

3-
import com.github.ilovegamecoding.intellijcodexp.services.CodeXPService;
4-
import com.intellij.openapi.application.ApplicationManager;
5-
63
import javax.swing.*;
74

85
public class CodeXPDashboard {
@@ -18,4 +15,5 @@ public class CodeXPDashboard {
1815
public JPanel pCompletedChallenges;
1916
public JPanel pEventStatistics;
2017
public JPanel pChallenges;
18+
public JLabel lblCompletedChallengesCount;
2119
}

src/main/kotlin/com/github/ilovegamecoding/intellijcodexp/listeners/CodeXPEventListener.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ internal class CodeXPEventListener : AnActionListener {
3333
"Paste" -> fireEvent(CodeXPService.Event.PASTE)
3434
"Backspace" -> fireEvent(CodeXPService.Event.BACKSPACE)
3535
"Tab" -> fireEvent(CodeXPService.Event.TAB)
36+
else -> fireEvent(CodeXPService.Event.ACTION)
3637
}
3738
}
3839

src/main/kotlin/com/github/ilovegamecoding/intellijcodexp/model/CodeXPChallenge.kt

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
package com.github.ilovegamecoding.intellijcodexp.model
22

33
import com.github.ilovegamecoding.intellijcodexp.services.CodeXPService
4+
import java.util.*
45

56
/**
67
* CodeXPChallenge class
78
*
89
* CodeXPChallenge is a class that represents a challenge. Challenges are used to track the progress of the user.
910
*/
1011
class CodeXPChallenge() {
12+
/**
13+
* ID of challenge.
14+
*/
15+
var id: String = ""
16+
1117
/**
1218
* Event of challenge.
1319
*/
@@ -28,6 +34,11 @@ class CodeXPChallenge() {
2834
*/
2935
var rewardXP: Long = 0L
3036

37+
/**
38+
* Increment of reward XP of challenge when completed.
39+
*/
40+
var rewardXPIncrement: Long = 0L
41+
3142
/**
3243
* Current progress of challenge.
3344
*/
@@ -38,6 +49,11 @@ class CodeXPChallenge() {
3849
*/
3950
var goal: Long = 0L
4051

52+
/**
53+
* Increment of goal of challenge.
54+
*/
55+
var goalIncrement: Long = 0L
56+
4157
/**
4258
* Constructor for CodeXPChallenge with all parameters.
4359
*/
@@ -46,14 +62,19 @@ class CodeXPChallenge() {
4662
name: String,
4763
description: String,
4864
rewardXP: Long,
65+
rewardXPIncrement: Long,
4966
progress: Long,
50-
goal: Long
67+
goal: Long,
68+
goalIncrement: Long
5169
) : this() {
70+
this.id = UUID.randomUUID().toString()
5271
this.event = event
5372
this.name = name
5473
this.description = description
5574
this.rewardXP = rewardXP
75+
this.rewardXPIncrement = rewardXPIncrement
5676
this.progress = progress
5777
this.goal = goal
78+
this.goalIncrement = goalIncrement
5879
}
5980
}

0 commit comments

Comments
 (0)