Skip to content

Commit

Permalink
Fix loading defaults from image object def (#1659)
Browse files Browse the repository at this point in the history
Co-authored-by: wixoa <[email protected]>
  • Loading branch information
amylizzle and wixoaGit authored Feb 18, 2024
1 parent 7b16a79 commit b048ec4
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
14 changes: 14 additions & 0 deletions Content.Tests/DMProject/Tests/Image/subclass.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/image/subclass
plane = 123
icon_state = "subclass"

/proc/RunTest()
var/image/test = new /image/subclass
ASSERT(test.plane == 123)
ASSERT(test.icon_state == "subclass")
var/image/subclass/test2 = new(icon())
ASSERT(test2.plane == FLOAT_PLANE)
ASSERT(test2.icon_state == null)
var/image/subclass/test3 = new(icon_state="test")
ASSERT(test3.plane == 123)
ASSERT(test3.icon_state == "test")
8 changes: 7 additions & 1 deletion DMCompiler/DMStandard/Types/Image.dm
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@
var/appearance_flags = 0
var/blend_mode = 0
var/color = null
var/list/contents as opendream_unimplemented
var/density = 0 as opendream_unimplemented
var/desc = null
var/gender = "neuter" as opendream_unimplemented
var/glide_size = 0 as opendream_unimplemented
var/infra_luminosity = 0 as opendream_unimplemented
var/invisibility as opendream_unimplemented
var/list/filters = list()
Expand All @@ -25,9 +28,10 @@
var/mouse_drop_zone = 0 as opendream_unimplemented
var/mouse_opacity = 1
var/name = "image"
var/opacity as opendream_unimplemented
var/opacity = 0 as opendream_unimplemented
var/list/overlays = null
var/override = 0
var/pixel_step_size = 0 as opendream_unimplemented
var/pixel_x = 0
var/pixel_y = 0
var/pixel_w = 0 as opendream_unimplemented
Expand All @@ -39,6 +43,8 @@
var/text = "i" as opendream_unimplemented
var/matrix/transform
var/list/underlays = null
var/list/verbs as opendream_unimplemented
var/visibility = 1 as opendream_unimplemented
var/vis_flags = 0 as opendream_unimplemented

var/bound_width as opendream_unimplemented
Expand Down
2 changes: 2 additions & 0 deletions OpenDreamClient/Rendering/DreamPlane.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ public void Draw(DreamViewOverlay overlay, DrawingHandleWorld handle, Box2 world
/// Draws this plane's mouse map onto the current render target
/// </summary>
public void DrawMouseMap(DrawingHandleWorld handle, DreamViewOverlay overlay, Vector2i renderTargetSize, Box2 worldAABB) {
if (Master?.MouseOpacity == MouseOpacity.Transparent)
return;
handle.UseShader(overlay.BlockColorInstance);
foreach (var sprite in Sprites) {
if (sprite.MouseOpacity == MouseOpacity.Transparent || sprite.ShouldPassMouse)
Expand Down
4 changes: 2 additions & 2 deletions OpenDreamRuntime/Objects/Types/DreamObjectImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ public override void Initialize(DreamProcArguments args) {
base.Initialize(args);

DreamValue icon = args.GetArgument(0);
if (!AtomManager.TryCreateAppearanceFrom(icon, out Appearance)) {
if (icon.IsNull || !AtomManager.TryCreateAppearanceFrom(icon, out Appearance)) {
// Use a default appearance, but log a warning about it if icon wasn't null
Appearance = new IconAppearance();
Appearance = AtomManager.GetAppearanceFromDefinition(ObjectDefinition);
if (!icon.IsNull)
Logger.GetSawmill("opendream.image")
.Warning($"Attempted to create an /image from {icon}. This is invalid and a default image was created instead.");
Expand Down

0 comments on commit b048ec4

Please sign in to comment.