Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow custom widgets when loading MML #402

Merged
merged 2 commits into from
Sep 19, 2024

Conversation

spacechase0
Copy link
Contributor

@spacechase0 spacechase0 commented Oct 5, 2023

Example:

namespace MyGameProject;

public class ItemSlot : ButtonBase<Panel>
{
    // ...
}
Project.ExtraWidgetAssembliesAndNamespaces.Add( typeof( ItemSlot ).Assembly, new string[] { typeof( ItemSlot ).Namespace } );
Grid g = Project.LoadFromXml(File.ReadAllText(Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "assets/inventory.xmmp")), MyraUtil.AssetManager).Root as Grid;
var slots = g.GetChildren().Where(w => w is ItemSlot).Cast<ItemSlot>().ToArray();
slots[0].Stack = new Items.ItemStack("dagger") { Quantity = 1 };
<?xml version="1.0" encoding="UTF-8" ?>
<Project>
  <Project.ExportOptions />
  <Grid RowSpacing="4" ColumnSpacing="4">
    <Grid.DefaultColumnProportion Type="Pixels" Value="40"/>      
    <Grid.DefaultRowProportion Type="Pixels" Value="40"/>
    <ItemSlot GridRow="0" GridColumn="0" />
    <!-- a lot more of ItemSlot with different GridRow / GridColumn here -->
  </Grid>
</Project>

@benda
Copy link

benda commented Jul 31, 2024

@spacechase0 @rds1983 Can this be fixed and merged ? Seems very useful.

@rds1983 rds1983 merged commit 3ed960e into rds1983:master Sep 19, 2024
1 check failed
@rds1983
Copy link
Owner

rds1983 commented Sep 19, 2024

thanks @spacechase0 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants