Skip to content

Commit

Permalink
Merge branch 'upstream-master' into multi-banners
Browse files Browse the repository at this point in the history
  • Loading branch information
Rian8337 committed Jan 25, 2025
2 parents 565aa46 + e4c9207 commit 5ab3cd9
Show file tree
Hide file tree
Showing 76 changed files with 1,917 additions and 937 deletions.
12 changes: 12 additions & 0 deletions res/layout/multiplayer_room_chat_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@
android:gravity="right"
android:paddingHorizontal="6dp">

<TextView
android:id="@+id/timestamp_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="4dp"
android:gravity="right"
android:singleLine="true"
android:textColor="#ABABAB"
android:textSize="12sp"
tools:text="Timestamp"
tools:visibility="visible" />

<TextView
android:id="@+id/sender_text"
android:layout_width="160dp"
Expand Down
3 changes: 3 additions & 0 deletions res/values/strings_temporary_for_locals.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@
<item>1</item>
</string-array>

<string name="mp_room_max_players_title">Maximum Players</string>
<string name="mp_room_max_players_summary">Set the maximum number of players allowed in the room</string>

</resources>
11 changes: 10 additions & 1 deletion res/xml/multiplayer_room_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,16 @@
android:key="room_password"
android:summary="@string/mp_room_password_summary"
android:title="@string/mp_room_password_title"
app:layout="@layout/settings_preference_input_bottom" />
app:layout="@layout/settings_preference_input" />

<SeekBarPreference
android:key="room_max_players"
android:max="16"
android:min="2"
android:summary="@string/mp_room_max_players_summary"
android:title="@string/mp_room_max_players_title"
app:showSeekBarValue="true"
app:layout="@layout/settings_preference_seekbar_bottom" />

</PreferenceCategory>

Expand Down
8 changes: 8 additions & 0 deletions src/com/edlplan/osu/support/slider/SliderBody.java
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,19 @@ protected void onManagedUpdate(float pSecondsElapsed) {


public void setStartLength(float length) {
if (length == startLength) {
return;
}

startLength = length;
shouldRebuildVertices = true;
}

public void setEndLength(float length) {
if (length == endLength) {
return;
}

endLength = length;
shouldRebuildVertices = true;
}
Expand Down
5 changes: 4 additions & 1 deletion src/com/reco1l/BuildUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ class FakeSocket(private val uid: Long, private val username: String) : Socket(n
"playerModsChanged" -> "playerModsChanged" to arrayOf(uid.toString(), args[0])
"playerStatusChanged" -> "playerStatusChanged" to arrayOf(uid.toString(), args[0])

// These events requires special handling
// In these events, the client expects to receive an integer as the first argument.
"maxPlayersChanged" -> "maxPlayersChanged" to arrayOf(args[0].toString())

// These events require special handling
"roomGameplaySettingsChanged" -> "roomGameplaySettingsChanged" to arrayOf((args[0] as JSONObject).apply {
Multiplayer.room!!.gameplaySettings.also {
if (!has("isFreeMod")) put("isFreeMod", it.isFreeMod)
Expand Down
34 changes: 21 additions & 13 deletions src/com/reco1l/andengine/Anchor.kt
Original file line number Diff line number Diff line change
@@ -1,26 +1,34 @@
package com.reco1l.andengine

/**
* The anchor points in the range of [0, 1].
*/
enum class Anchor(val factorX: Float, val factorY: Float) {
import com.reco1l.framework.math.Vec2

TopLeft(0f, 0f),
object Anchor {

TopCenter(0.5f, 0f),
@JvmField
val TopLeft = Vec2(0f, 0f)

TopRight(1f, 0f),
@JvmField
val TopCenter = Vec2(0.5f, 0f)

CenterLeft(0f, 0.5f),
@JvmField
val TopRight = Vec2(1f, 0f)

Center(0.5f, 0.5f),
@JvmField
val CenterLeft = Vec2(0f, 0.5f)

CenterRight(1f, 0.5f),
@JvmField
val Center = Vec2(0.5f, 0.5f)

BottomLeft(0f, 1f),
@JvmField
val CenterRight = Vec2(1f, 0.5f)

BottomCenter(0.5f, 1f),
@JvmField
val BottomLeft = Vec2(0f, 1f)

BottomRight(1f, 1f)
@JvmField
val BottomCenter = Vec2(0.5f, 1f)

@JvmField
val BottomRight = Vec2(1f, 1f)

}
2 changes: 1 addition & 1 deletion src/com/reco1l/andengine/Axes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ enum class Axes {


/**
* Whether this axis [Y] or [Both].
* Whether this axis is [Y] or [Both].
*/
val isVertical: Boolean
get() = this == Y || this == Both
Expand Down
59 changes: 59 additions & 0 deletions src/com/reco1l/andengine/BlendInfo.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package com.reco1l.andengine

import javax.microedition.khronos.opengles.GL10

data class BlendInfo(

/**
* The blending function to use.
*/
var function: BlendingFunction,

/**
* Whether to mask the red channel.
*/
var redMask: Boolean = true,

/**
* Whether to mask the green channel.
*/
var greenMask: Boolean = true,

/**
* Whether to mask the blue channel.
*/
var blueMask: Boolean = true,

/**
* Whether to mask the alpha channel.
*/
var alphaMask: Boolean = true,

/**
* Whether to clear the color buffer.
*/
var clear: Boolean = false

) {

fun apply(gl: GL10) {

gl.glColorMask(redMask, greenMask, blueMask, alphaMask)

if (function != BlendingFunction.Inherit) {
gl.glBlendFunc(function.source, function.destination)
}

if (clear) {
gl.glClear(GL10.GL_COLOR_BUFFER_BIT)
}
}


companion object {

val Inherit = BlendInfo(BlendingFunction.Inherit)

}

}
12 changes: 12 additions & 0 deletions src/com/reco1l/andengine/DepthInfo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,24 @@ package com.reco1l.andengine
import org.anddev.andengine.opengl.util.GLHelper
import javax.microedition.khronos.opengles.GL10

/**
* Information about how to behave with the depth buffer.
*/
data class DepthInfo(

/**
* The depth function to use.
*/
val function: DepthFunction,

/**
* Whether to write to the depth buffer.
*/
val mask: Boolean,

/**
* Whether to clear the depth buffer.
*/
val clear: Boolean

) {
Expand Down
123 changes: 123 additions & 0 deletions src/com/reco1l/andengine/Entities.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
package com.reco1l.andengine

import com.reco1l.framework.math.Vec2
import com.reco1l.framework.math.Vec4
import org.anddev.andengine.entity.IEntity
import org.anddev.andengine.entity.scene.CameraScene
import org.anddev.andengine.entity.shape.IShape


fun IEntity?.getPadding() = when (this) {
is ExtendedEntity -> padding
else -> Vec4.Zero
}

fun IEntity?.getPaddedWidth() = when (this) {
is ExtendedEntity -> drawWidth - padding.horizontal
is CameraScene -> camera.widthRaw
is IShape -> width
else -> 0f
}

fun IEntity?.getPaddedHeight() = when (this) {
is ExtendedEntity -> drawHeight - padding.vertical
is CameraScene -> camera.heightRaw
is IShape -> height
else -> 0f
}


/**
* The size of the entity.
*
* When using the getter this will return the maximum value between the width and height or the same.
* When using the setter this will set the width and height to the same value.
*/
var ExtendedEntity.size
get() = Vec2(width, height)
set(value) {
width = value.x
height = value.y
}


/**
* The total offset applied to the X axis.
*/
val ExtendedEntity.totalOffsetX
get() = originOffsetX + anchorOffsetX + translationX

/**
* The total offset applied to the Y axis.
*/
val ExtendedEntity.totalOffsetY
get() = originOffsetY + anchorOffsetY + translationY

/**
* The offset applied to the X axis according to the anchor factor.
*/
val ExtendedEntity.anchorOffsetX: Float
get() = parent.getPaddedWidth() * anchor.x

/**
* The offset applied to the Y axis according to the anchor factor.
*/
val ExtendedEntity.anchorOffsetY: Float
get() = parent.getPaddedHeight() * anchor.y

/**
* The offset applied to the X axis according to the origin factor.
*/
val ExtendedEntity.originOffsetX: Float
get() = -(drawWidth * origin.x)

/**
* The offset applied to the Y axis according to the origin factor.
*/
val ExtendedEntity.originOffsetY: Float
get() = -(drawHeight * origin.y)


/**
* Returns the draw width of the entity.
*/
fun IEntity?.getDrawWidth(): Float = when (this) {
is ExtendedEntity -> drawWidth
is IShape -> width
else -> 0f
}

/**
* Returns the draw height of the entity.
*/
fun IEntity?.getDrawHeight(): Float = when (this) {
is ExtendedEntity -> drawHeight
is IShape -> height
else -> 0f
}

/**
* Returns the draw X position of the entity.
*/
fun IEntity?.getDrawX(): Float = when (this) {
is ExtendedEntity -> drawX
is IShape -> x
else -> 0f
}

/**
* Returns the draw Y position of the entity.
*/
fun IEntity?.getDrawY(): Float = when (this) {
is ExtendedEntity -> drawY
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
}
8 changes: 6 additions & 2 deletions src/com/reco1l/andengine/EntityCollision.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ object EntityCollision {
private val vertices = FloatArray(8)


fun contains(entity: ExtendedEntity, x: Float, y: Float): Boolean {
fun contains(entity: ExtendedEntity, x: Float, y: Float, fromScene: Boolean): Boolean {

val left = 0f
val top = 0f
Expand All @@ -29,7 +29,11 @@ object EntityCollision {
vertices[6 + VERTEX_INDEX_X] = left
vertices[6 + VERTEX_INDEX_Y] = bottom

entity.getLocalToSceneTransformation().transform(vertices)
if (fromScene) {
entity.localToSceneTransformation.transform(vertices)
} else {
entity.localToParentTransformation.transform(vertices)
}

return ShapeCollisionChecker.checkContains(vertices, vertices.size, x, y)
}
Expand Down
Loading

0 comments on commit 5ab3cd9

Please sign in to comment.