Skip to content

Commit

Permalink
Merge pull request #485 from Reco1I/hud-layout
Browse files Browse the repository at this point in the history
Implement HUD layout editor
  • Loading branch information
Rian8337 authored Mar 1, 2025
2 parents 66d04b0 + 6d268db commit 72a5f16
Show file tree
Hide file tree
Showing 45 changed files with 2,391 additions and 854 deletions.
Binary file added assets/delete.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 added assets/one-one.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions res/values/strings_temporary_for_locals.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,20 @@
<string name="opt_snakingOutSliders_title">Use snaking out sliders</string>
<string name="opt_snakingOutSliders_summary">Enable sliders gradually snaking disappearing from one node</string>

<!-- HUD editor -->

<string name="opt_hudEditor_title">HUD Editor</string>
<string name="opt_hudEditor_summary">Edit the HUD layout as you like</string>

<string name="hudEditor_modal_title">HUD Editor</string>
<string name="hudEditor_modal_save">Exit and save changes</string>
<string name="hudEditor_modal_discard">Discard changes</string>
<string name="hudEditor_modal_reset">Reset to default</string>
<string name="hudEditor_modal_cancel">Cancel</string>

<string name="hudEditor_saving">Saving changes...</string>
<string name="hudEditor_saved">Changes saved!</string>
<string name="hudEditor_discarded">Changes discarded!</string>
<string name="hudEditor_reset">HUD set to default!</string>

</resources>
49 changes: 6 additions & 43 deletions res/xml/settings_gameplay.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
android:summary="@string/opt_skinpath_summary"
android:title="@string/opt_skinpath_title" />

<Preference
android:key="hud_editor"
android:summary="@string/opt_hudEditor_summary"
android:title="@string/opt_hudEditor_title"
app:layout="@layout/settings_preference"/>

<com.reco1l.osu.ui.SelectPreference
android:defaultValue="1"
android:entries="@array/spinner_style_names"
Expand Down Expand Up @@ -68,14 +74,6 @@

<PreferenceCategory android:title="@string/opt_category_hud">

<com.reco1l.osu.ui.SelectPreference
android:defaultValue="0"
android:entries="@array/opt_progress_indicator_names"
android:entryValues="@array/opt_progress_indicator_values"
android:key="progressIndicatorType"
android:summary="@string/opt_progress_indicator_summary"
android:title="@string/opt_progress_indicator_title" />

<CheckBoxPreference
android:defaultValue="false"
android:key="hideInGameUI"
Expand All @@ -88,54 +86,19 @@
android:summary="@string/opt_hide_replay_marquee_summary"
android:title="@string/opt_hide_replay_marquee_title" />

<CheckBoxPreference
android:key="showscoreboard"
android:summary="@string/opt_show_leaderboard_summary"
android:title="@string/opt_show_leaderboard_title" />

<com.reco1l.osu.ui.SelectPreference
android:defaultValue="0"
android:entries="@array/error_meter_display_names"
android:entryValues="@array/error_meter_display_values"
android:key="errormeter"
android:summary="@string/opt_error_meter_display_summary"
android:title="@string/opt_error_meter_display_title" />

<CheckBoxPreference
android:defaultValue="true"
android:key="fps"
android:summary="@string/opt_fps_summary"
android:title="@string/opt_fps_title"
app:layout="@layout/settings_preference_checkbox" />

<CheckBoxPreference
android:defaultValue="true"
android:key="averageOffset"
android:summary="@string/opt_averageoffset_summary"
android:title="@string/opt_averageoffset_title"
app:layout="@layout/settings_preference_checkbox" />

<CheckBoxPreference
android:defaultValue="true"
android:key="unstableRate"
android:summary="@string/opt_unstablerate_summary"
android:title="@string/opt_unstablerate_title"
app:layout="@layout/settings_preference_checkbox" />

<CheckBoxPreference
android:defaultValue="true"
android:key="displayScoreStatistics"
android:summary="@string/opt_display_score_statistics_summary"
android:title="@string/opt_display_score_statistics_title" />

<CheckBoxPreference
android:defaultValue="false"
android:key="displayRealTimePPCounter"
android:summary="@string/opt_display_realtime_pp_counter_summary"
android:title="@string/opt_display_realtime_pp_counter_title"
app:layout="@layout/settings_preference_checkbox_bottom" />


</PreferenceCategory>

<PreferenceCategory android:title="@string/opt_combo_colors_title">
Expand Down
9 changes: 0 additions & 9 deletions src/com/edlplan/ui/fragment/ModSettingsMenu.kt
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,6 @@ class ModSettingsMenu : BaseFragment() {
}
}

findViewById<CheckBox>(R.id.showScoreboard)!!.apply {
isChecked = Config.isShowScoreboard()
setOnCheckedChangeListener { _, isChecked ->
Config.setShowScoreboard(isChecked)
PreferenceManager.getDefaultSharedPreferences(context).edit()
.putBoolean("showscoreboard", isChecked).commit()
}
}

findViewById<CheckBox>(R.id.enableVideo)!!.apply {
isChecked = Config.isVideoEnabled()
setOnCheckedChangeListener { _, isChecked ->
Expand Down
45 changes: 45 additions & 0 deletions src/com/reco1l/andengine/Anchor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,49 @@ object Anchor {
@JvmField
val BottomRight = Vec2(1f, 1f)


val all by lazy {
listOf(
TopLeft,
TopCenter,
TopRight,
CenterLeft,
Center,
CenterRight,
BottomLeft,
BottomCenter,
BottomRight
)
}

fun getName(anchor: Vec2): String {
return when (anchor) {
TopLeft -> "TopLeft"
TopCenter -> "TopCenter"
TopRight -> "TopRight"
CenterLeft -> "CenterLeft"
Center -> "Center"
CenterRight -> "CenterRight"
BottomLeft -> "BottomLeft"
BottomCenter -> "BottomCenter"
BottomRight -> "BottomRight"
else -> throw IllegalArgumentException("Unknown anchor point: $anchor")
}
}

fun getFromName(name: String): Vec2 {
return when (name) {
"TopLeft" -> TopLeft
"TopCenter" -> TopCenter
"TopRight" -> TopRight
"CenterLeft" -> CenterLeft
"Center" -> Center
"CenterRight" -> CenterRight
"BottomLeft" -> BottomLeft
"BottomCenter" -> BottomCenter
"BottomRight" -> BottomRight
else -> throw IllegalArgumentException("Unknown anchor point: $name")
}
}

}
80 changes: 70 additions & 10 deletions src/com/reco1l/andengine/Entities.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,64 @@ fun IEntity?.getPaddedHeight() = when (this) {
var ExtendedEntity.size
get() = Vec2(width, height)
set(value) {
width = value.x
height = value.y
setSize(value.x, value.y)
}

/**
* The draw size of the entity.
*/
val ExtendedEntity.drawSize
get() = Vec2(drawWidth, drawHeight)

/**
* The position of the entity.
*/
var ExtendedEntity.position
get() = Vec2(x, y)
set(value) {
setPosition(value.x, value.y)
}

/**
* The draw position of the entity.
*/
val ExtendedEntity.drawPosition
get() = Vec2(drawX, drawY)


/**
* The scale of the entity.
*/
var ExtendedEntity.scale
get() = Vec2(scaleX, scaleY)
set(value) {
setScale(value.x, value.y)
}

/**
* The center where the entity will scale from.
*/
var ExtendedEntity.scaleCenter
get() = Vec2(scaleCenterX, scaleCenterY)
set(value) {
setScaleCenter(value.x, value.y)
}

/**
* The center where the entity will rotate from.
*/
var ExtendedEntity.rotationCenter
get() = Vec2(rotationCenterX, rotationCenterY)
set(value) {
setRotationCenter(value.x, value.y)
}


/**
* The total offset applied to the entity.
*/
val ExtendedEntity.totalOffset
get() = Vec2(totalOffsetX, totalOffsetY)

/**
* The total offset applied to the X axis.
Expand All @@ -53,6 +107,13 @@ val ExtendedEntity.totalOffsetX
val ExtendedEntity.totalOffsetY
get() = originOffsetY + anchorOffsetY + translationY


/**
* The offset applied to the entity according to the anchor factor.
*/
val ExtendedEntity.anchorOffset
get() = Vec2(anchorOffsetX, anchorOffsetY)

/**
* The offset applied to the X axis according to the anchor factor.
*/
Expand All @@ -65,6 +126,13 @@ val ExtendedEntity.anchorOffsetX: Float
val ExtendedEntity.anchorOffsetY: Float
get() = parent.getPaddedHeight() * anchor.y


/**
* The offset applied to the entity according to the origin factor.
*/
val ExtendedEntity.originOffset
get() = Vec2(originOffsetX, originOffsetY)

/**
* The offset applied to the X axis according to the origin factor.
*/
Expand Down Expand Up @@ -113,11 +181,3 @@ fun IEntity?.getDrawY(): Float = when (this) {
is IShape -> y
else -> 0f
}

/**
* Attaches the entity to a parent.
*/
infix fun <T : IEntity> T.attachTo(parent: IEntity): T {
parent.attachChild(this)
return this
}
Loading

0 comments on commit 72a5f16

Please sign in to comment.