Mogre 1.7.3 with Miyagi 1.2

thefinalsql

22-12-2012 16:19:16

Windows 7 Ultimate 64bit, VS2010

Started with Cygon's 1.7.3 build. Compiled and ran fine. Have not applied the patch.

Added to it Miyagi 1.2 via Nuget.

Then spliced in Aralox newbie code.

It compiles, but running it gives error:

Could not load file or assembly 'MOIS, Version=1.1.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.

I ran Dependency Walker. Do not see any missing DLLs.

Do I need to patch Cygon's 1.7.3 build or use a different MOIS.dll?

Thanks!

using System;
using System.Collections.Generic;
using Miyagi.UI.Controls.Layout;
using Miyagi.Common.Data;
using Miyagi.Common.Resources;
using Miyagi.Common;
using Miyagi.UI;
using Miyagi.UI.Controls;

using Mogre;
using Mogre.TutorialFramework;

namespace MogreTest
{
class Program : BaseApplication
{
Dictionary<string, Skin> skinDict;
Dictionary<string, Miyagi.Common.Resources.Font> fonts;
MiyagiSystem system;
GUI gui;

ProgressBar progress;
float barval = 0;

static void Main(string[] args)
{
using (var program = new Program())
{
program.Go();
}

#if false
Root root = new Root();
printAvailableRenderers(root);
Console.ReadKey();
root.Shutdown();
#endif
}

protected override void CreateScene()
{
base.CreateScene();

system = new MiyagiSystem("Mogre");
gui = new GUI();
system.GUIManager.GUIs.Add(gui);

// Make sure mKeyboard and mMouse have already been created when doing this in your system
// Note: If you use the precompiled Mogre.TutorialFramework dll from the wiki, they actually create
// the input system AFTER CreateScene() is called, so the miyagi input doesnt work. (it was quite
// an annoying bug to find)
system.PluginManager.LoadPlugin(@"Miyagi.Plugin.Input.Mois.dll", mKeyboard, mMouse);

// Create a cube for fun
var ent = mSceneMgr.CreateEntity(Mogre.SceneManager.PrefabType.PT_CUBE);
var node = mSceneMgr.RootSceneNode.CreateChildSceneNode();
node.AttachObject(ent);

// Create font dictionary
fonts = new Dictionary<string, Miyagi.Common.Resources.Font>();

// Note: When loading fonts, the font file is loaded without the help of Mogre, so you must include the full path
// inside the TrueTypeFonts.xml. Hopefully theres an easier way, but I havent found it yet.
foreach (Miyagi.Common.Resources.Font font in TrueTypeFont.CreateFromXml("../../Media/TrueTypeFonts.xml", system))
fonts.Add(font.Name, font);

Miyagi.Common.Resources.Font.Default = fonts["BlueHighway"];

// Load some skins. Unlike fonts, the images ARE loaded using Mogre, so you can have the images anywhere referenced
// by your resources.cfg file
Skin cursorSkin = Skin.CreateFromXml("../../Media/cursorSkin.xml")[0];

var skins = Skin.CreateFromXml("../../Media/testSkin_map.skin"); //also an xml file, just a different extension
skinDict = new Dictionary<string, Skin>();

foreach (Skin skin in skins)
skinDict.Add(skin.Name, skin);

// Button - Note that you cannot click on this, as it is behind the TableLayoutPanel.
// Just move it to the side or resize the table to fix this
Button button = new Button();
button.Size = new Size(200, 100);
button.Location = new Point(50, 500);
button.Skin = skinDict["Button"];
gui.Controls.Add(button);

// Label
Label label = new Label();
label.Size = new Size(100, 50);
label.Location = new Point(500, 500);
label.Text = "Hello Miyagi";
gui.Controls.Add(label);

// Cursor
Cursor cursor = new Cursor(cursorSkin, new Size(50, 50), new Point(0, 0), true);
system.GUIManager.Cursor = cursor;

// Progressbar
progress = new ProgressBar();
progress.Size = new Size(300, 50);
progress.Skin = skinDict["ProgressBarH"];
progress.Location = new Point(50, 50);
gui.Controls.Add(progress);

// Table
TableLayoutPanel table = new TableLayoutPanel();
table.Location = new Point(50, 300);
table.Size = new Size(500, 500);

table.RowCount = 5;
table.ColumnCount = 5;

// Make sure you create the TableLayoutStyle objects, and add them to the table's column styles and row styles
// (dont need to do this for flow layout)
var colStyles = new TableLayoutStyle[table.RowCount];
var rowStyles = new TableLayoutStyle[table.ColumnCount];

for (int i = 0; i < colStyles.Length; i++)
colStyles = new TableLayoutStyle(SizeType.Absolute, 60); //width

for (int i = 0; i < rowStyles.Length; i++)
rowStyles = new TableLayoutStyle(SizeType.Absolute, 50); //height

table.ColumnStyles.AddRange(colStyles);
table.RowStyles.AddRange(rowStyles);

for (int i = 0; i < table.RowCount + table.ColumnCount; i++)
{
Button b = new Button();
b.Size = new Size(50, 50);
b.Skin = skinDict["Button"];
table.Controls.Add(b);
}

gui.Controls.Add(table);

// Flow layout panel
FlowLayoutPanel flowPanel = new FlowLayoutPanel();
flowPanel.Size = new Size(300, 500);
flowPanel.Location = new Point(600, 50);

for (int i = 0; i < 5; i++)
{
Button b = new Button();
b.Size = new Size(50, 50);
b.Skin = skinDict["Button"];
flowPanel.Controls.Add(b);
}

Button b2 = new Button();
b2.Size = new Size(80, 80); // Put in the middle to see the effect it has on the flow panel
b2.Skin = skinDict["Button"];
flowPanel.Controls.Add(b2);

for (int i = 0; i < 5; i++)
{
Button b = new Button();
b.Size = new Size(50, 50);
b.Skin = skinDict["Button"];
flowPanel.Controls.Add(b);
}

gui.Controls.Add(flowPanel);

//mSceneMgr.AmbientLight = new ColourValue(1, 1, 1);
//Entity ent = mSceneMgr.CreateEntity("Head", "ogrehead.mesh");
//SceneNode node = mSceneMgr.RootSceneNode.CreateChildSceneNode("HeadNode");
//node.AttachObject(ent);
}

protected override void UpdateScene(Mogre.FrameEvent evt)
{
barval += 0.1f;
progress.Value = (int)barval;

system.Update();
base.UpdateScene(evt);
}

private static void printAvailableRenderers(Root root)
{
Console.WriteLine(new string('-', 80));
Console.WriteLine("Available renderers: ");

Const_RenderSystemList renderers = root.GetAvailableRenderers();
for (int index = 0; index < renderers.Count; ++index)
{
Console.WriteLine("\t" + renderers[index].Name);
}

Console.WriteLine();
Console.WriteLine(new string('-', 80));
}
}

} // namespace MogreTest

smiley80

22-12-2012 17:35:48


Added to it Miyagi 1.2 via Nuget.

Please don't use that.

Download the stable version:
http://sourceforge.net/projects/miyagi/files/1.2/

Or compile from source:
https://bitbucket.org/tbohnen/miyagi

An attempt was made to load a program with an incorrect format.
Compile your project with 'x86' as target cpu.

RcALTIN

22-12-2012 17:49:42

I recommend you that, don't waste your time with above 1.7.1 versions of Mogre if it is not necessary. Just check these following topics, especially my posts and give up trying to compile guis :)

viewtopic.php?f=8&t=29664
viewtopic.php?f=8&t=29359

Use 1.7.1, if you want to work with any gui. Even if you know c++, use pure ogre wihout add-on pain...