What do I put in "GetDlgItem()" when initializing CListbox - listbox

Hi all I was hoping you'd help me.
I have a form, mainForm.h, with a listbox(among other things). I'd like to add an item to the listbox from another file. I declared the CListbox but don't know what to use inside the GetDlgItem(/In Here/) because I don't know my listbox's ID.
Here's how I initialized it the listbox in the other CPP file to call "actionLogBox":
clistBox* actionLogBox = dynamic_cast<CListBox*>(GetDlgItem(/*No IDea what to put here*/));
Here is my mainForm.h with the listbox called "actionLogBox":
#pragma once
# include "stdafx.h"
# include "addBase.h"
# include "serial.h"
#include "base_station.h"
namespace WCM {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
/// <summary>
/// Summary for mainForm
/// </summary>
public ref class mainForm : public System::Windows::Forms::Form
{
public:
mainForm(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~mainForm()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::MenuStrip^ menuStrip1;
private: System::Windows::Forms::ToolStripMenuItem^ fileMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^ expDataDirMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^ uploadDataMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^ exitMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^ editMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^ prefMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^ helpMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^ aboutMenuItem;
private: System::Windows::Forms::ToolStrip^ toolStrip1;
private: System::Windows::Forms::ToolStripDropDownButton^ addBaseButton;
private: System::Windows::Forms::ToolStripMenuItem^ scanPortsMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^ addBaseMenuItem;
private: System::Windows::Forms::ToolStripDropDownButton^ addNodesButton;
private: System::Windows::Forms::ToolStripMenuItem^ nodeDiscMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^ addNodeMenuItem;
private: System::Windows::Forms::ToolStripSeparator^ toolStripSeparator1;
private: System::Windows::Forms::ToolStripButton^ nodesInfoButton;
private: System::Windows::Forms::ToolStripButton^ nodesConfigButton;
private: System::Windows::Forms::GroupBox^ bottomBox;
private: System::Windows::Forms::ListBox^ actionLogBox;
private: System::Windows::Forms::ListBox^ baseStationBox;
private: System::Windows::Forms::GroupBox^ sideBox;
protected:
private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(mainForm::typeid));
this->menuStrip1 = (gcnew System::Windows::Forms::MenuStrip());
this->fileMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->expDataDirMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->uploadDataMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->exitMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->editMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->prefMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->helpMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->aboutMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->toolStrip1 = (gcnew System::Windows::Forms::ToolStrip());
this->addBaseButton = (gcnew System::Windows::Forms::ToolStripDropDownButton());
this->scanPortsMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->addBaseMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->addNodesButton = (gcnew System::Windows::Forms::ToolStripDropDownButton());
this->nodeDiscMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->addNodeMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->toolStripSeparator1 = (gcnew System::Windows::Forms::ToolStripSeparator());
this->nodesInfoButton = (gcnew System::Windows::Forms::ToolStripButton());
this->nodesConfigButton = (gcnew System::Windows::Forms::ToolStripButton());
this->bottomBox = (gcnew System::Windows::Forms::GroupBox());
this->actionLogBox = (gcnew System::Windows::Forms::ListBox());
this->baseStationBox = (gcnew System::Windows::Forms::ListBox());
this->sideBox = (gcnew System::Windows::Forms::GroupBox());
this->menuStrip1->SuspendLayout();
this->toolStrip1->SuspendLayout();
this->bottomBox->SuspendLayout();
this->sideBox->SuspendLayout();
this->SuspendLayout();
//
// menuStrip1
//
this->menuStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(3) {
this->fileMenuItem, this->editMenuItem,
this->helpMenuItem
});
this->menuStrip1->Location = System::Drawing::Point(0, 0);
this->menuStrip1->Name = L"menuStrip1";
this->menuStrip1->Size = System::Drawing::Size(638, 24);
this->menuStrip1->TabIndex = 0;
this->menuStrip1->Text = L"menuStrip1";
//
// fileMenuItem
//
this->fileMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(3) {
this->expDataDirMenuItem,
this->uploadDataMenuItem, this->exitMenuItem
});
this->fileMenuItem->Name = L"fileMenuItem";
this->fileMenuItem->Size = System::Drawing::Size(37, 20);
this->fileMenuItem->Text = L"File";
//
// expDataDirMenuItem
//
this->expDataDirMenuItem->Name = L"expDataDirMenuItem";
this->expDataDirMenuItem->Size = System::Drawing::Size(190, 22);
this->expDataDirMenuItem->Text = L"Explore Data Directory";
//
// uploadDataMenuItem
//
this->uploadDataMenuItem->Name = L"uploadDataMenuItem";
this->uploadDataMenuItem->Size = System::Drawing::Size(190, 22);
this->uploadDataMenuItem->Text = L"Upload Data";
//
// exitMenuItem
//
this->exitMenuItem->Name = L"exitMenuItem";
this->exitMenuItem->Size = System::Drawing::Size(190, 22);
this->exitMenuItem->Text = L"Exit";
//
// editMenuItem
//
this->editMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(1) { this->prefMenuItem });
this->editMenuItem->Name = L"editMenuItem";
this->editMenuItem->Size = System::Drawing::Size(39, 20);
this->editMenuItem->Text = L"Edit";
//
// prefMenuItem
//
this->prefMenuItem->Name = L"prefMenuItem";
this->prefMenuItem->Size = System::Drawing::Size(135, 22);
this->prefMenuItem->Text = L"Preferences";
//
// helpMenuItem
//
this->helpMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(1) { this->aboutMenuItem });
this->helpMenuItem->Name = L"helpMenuItem";
this->helpMenuItem->Size = System::Drawing::Size(44, 20);
this->helpMenuItem->Text = L"Help";
//
// aboutMenuItem
//
this->aboutMenuItem->Name = L"aboutMenuItem";
this->aboutMenuItem->Size = System::Drawing::Size(107, 22);
this->aboutMenuItem->Text = L"About";
//
// toolStrip1
//
this->toolStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(5) {
this->addBaseButton, this->addNodesButton,
this->toolStripSeparator1, this->nodesInfoButton, this->nodesConfigButton
});
this->toolStrip1->Location = System::Drawing::Point(0, 24);
this->toolStrip1->Name = L"toolStrip1";
this->toolStrip1->Size = System::Drawing::Size(638, 25);
this->toolStrip1->TabIndex = 1;
this->toolStrip1->Text = L"toolStrip1";
//
// addBaseButton
//
this->addBaseButton->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image;
this->addBaseButton->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(2) {
this->scanPortsMenuItem,
this->addBaseMenuItem
});
this->addBaseButton->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"addBaseButton.Image")));
this->addBaseButton->ImageTransparentColor = System::Drawing::Color::Magenta;
this->addBaseButton->Name = L"addBaseButton";
this->addBaseButton->Size = System::Drawing::Size(29, 22);
this->addBaseButton->Text = L"Add Base";
//
// scanPortsMenuItem
//
this->scanPortsMenuItem->Name = L"scanPortsMenuItem";
this->scanPortsMenuItem->Size = System::Drawing::Size(129, 22);
this->scanPortsMenuItem->Text = L"Scan Ports";
//
// addBaseMenuItem
//
this->addBaseMenuItem->Name = L"addBaseMenuItem";
this->addBaseMenuItem->Size = System::Drawing::Size(129, 22);
this->addBaseMenuItem->Text = L"Add Base";
this->addBaseMenuItem->Click += gcnew System::EventHandler(this, &mainForm::addBaseMenuItem_Click);
//
// addNodesButton
//
this->addNodesButton->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image;
this->addNodesButton->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(2) {
this->nodeDiscMenuItem,
this->addNodeMenuItem
});
this->addNodesButton->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"addNodesButton.Image")));
this->addNodesButton->ImageTransparentColor = System::Drawing::Color::Magenta;
this->addNodesButton->Name = L"addNodesButton";
this->addNodesButton->Size = System::Drawing::Size(29, 22);
this->addNodesButton->Text = L"Add Nodes";
//
// nodeDiscMenuItem
//
this->nodeDiscMenuItem->Name = L"nodeDiscMenuItem";
this->nodeDiscMenuItem->Size = System::Drawing::Size(157, 22);
this->nodeDiscMenuItem->Text = L"Node Discovery";
//
// addNodeMenuItem
//
this->addNodeMenuItem->Name = L"addNodeMenuItem";
this->addNodeMenuItem->Size = System::Drawing::Size(157, 22);
this->addNodeMenuItem->Text = L"Add Node";
//
// toolStripSeparator1
//
this->toolStripSeparator1->Name = L"toolStripSeparator1";
this->toolStripSeparator1->Size = System::Drawing::Size(6, 25);
//
// nodesInfoButton
//
this->nodesInfoButton->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image;
this->nodesInfoButton->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"nodesInfoButton.Image")));
this->nodesInfoButton->ImageTransparentColor = System::Drawing::Color::Magenta;
this->nodesInfoButton->Name = L"nodesInfoButton";
this->nodesInfoButton->Size = System::Drawing::Size(23, 22);
this->nodesInfoButton->Text = L"Load Node Information";
this->nodesInfoButton->ToolTipText = L"Load Nodes Information";
//
// nodesConfigButton
//
this->nodesConfigButton->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image;
this->nodesConfigButton->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"nodesConfigButton.Image")));
this->nodesConfigButton->ImageTransparentColor = System::Drawing::Color::Magenta;
this->nodesConfigButton->Name = L"nodesConfigButton";
this->nodesConfigButton->Size = System::Drawing::Size(23, 22);
this->nodesConfigButton->Text = L"Configure Nodes";
//
// bottomBox
//
this->bottomBox->Controls->Add(this->actionLogBox);
this->bottomBox->Location = System::Drawing::Point(0, 281);
this->bottomBox->Name = L"bottomBox";
this->bottomBox->Size = System::Drawing::Size(638, 119);
this->bottomBox->TabIndex = 3;
this->bottomBox->TabStop = false;
this->bottomBox->Text = L"Action Log";
this->bottomBox->Enter += gcnew System::EventHandler(this, &mainForm::groupBox1_Enter);
//
// actionLogBox
//
this->actionLogBox->Anchor = static_cast<System::Windows::Forms::AnchorStyles>(((System::Windows::Forms::AnchorStyles::Bottom | System::Windows::Forms::AnchorStyles::Left)
| System::Windows::Forms::AnchorStyles::Right));
this->actionLogBox->BackColor = System::Drawing::SystemColors::Window;
this->actionLogBox->ForeColor = System::Drawing::SystemColors::InactiveCaptionText;
this->actionLogBox->FormattingEnabled = true;
this->actionLogBox->Items->AddRange(gcnew cli::array< System::Object^ >(1) { L"--- Ready ---" });
this->actionLogBox->Location = System::Drawing::Point(6, 17);
this->actionLogBox->Name = L"actionLogBox";
this->actionLogBox->Size = System::Drawing::Size(626, 95);
this->actionLogBox->TabIndex = 0;
this->actionLogBox->SelectedIndexChanged += gcnew System::EventHandler(this, &mainForm::actionLogBox_SelectedIndexChanged);
//
// baseStationBox
//
this->baseStationBox->BackColor = System::Drawing::SystemColors::Window;
this->baseStationBox->ForeColor = System::Drawing::SystemColors::InactiveCaptionText;
this->baseStationBox->FormattingEnabled = true;
this->baseStationBox->Items->AddRange(gcnew cli::array< System::Object^ >(1) { L"(Add a Base Station)" });
this->baseStationBox->Location = System::Drawing::Point(6, 19);
this->baseStationBox->Name = L"baseStationBox";
this->baseStationBox->Size = System::Drawing::Size(128, 199);
this->baseStationBox->TabIndex = 5;
this->baseStationBox->SelectedIndexChanged += gcnew System::EventHandler(this, &mainForm::baseStationBox_SelectedIndexChanged);
//
// sideBox
//
this->sideBox->Controls->Add(this->baseStationBox);
this->sideBox->Location = System::Drawing::Point(6, 52);
this->sideBox->Name = L"sideBox";
this->sideBox->Size = System::Drawing::Size(134, 225);
this->sideBox->TabIndex = 6;
this->sideBox->TabStop = false;
this->sideBox->Text = L"Base Station Controller";
//
// mainForm
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(638, 400);
this->Controls->Add(this->sideBox);
this->Controls->Add(this->bottomBox);
this->Controls->Add(this->toolStrip1);
this->Controls->Add(this->menuStrip1);
this->MainMenuStrip = this->menuStrip1;
this->Name = L"mainForm";
this->StartPosition = System::Windows::Forms::FormStartPosition::CenterScreen;
this->Text = L"Wireless Controll Manager";
this->Load += gcnew System::EventHandler(this, &mainForm::mainForm_Load);
this->menuStrip1->ResumeLayout(false);
this->menuStrip1->PerformLayout();
this->toolStrip1->ResumeLayout(false);
this->toolStrip1->PerformLayout();
this->bottomBox->ResumeLayout(false);
this->sideBox->ResumeLayout(false);
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
private: System::Void addBaseMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
addBase^ add_base = gcnew addBase();
add_base->ShowDialog();
}
private: System::Void groupBox1_Enter(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void mainForm_Load(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void baseStationBox_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void actionLogBox_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) {
actionLogBox->Items->Add("Blue") /*Test*/
}
};
}

Related

How to get the information of DeclRefExpr from the basic block in Clang:CFG?

How to get the information of DeclRefExpr from the basic block in Clang:CFG?
This is code i have coded
class CFGPrinter : public MatchFinder::MatchCallback {
public:
virtual void run(const MatchFinder::MatchResult &Result) {
if (const FunctionDecl *funcDecl =
Result.Nodes.getNodeAs<clang::FunctionDecl>("mainFunction")) {
ASTContext *context = Result.Context;
Stmt *funcBody = funcDecl->getBody();
static std::unique_ptr<CFG> sourceCFG = CFG::buildCFG(funcDecl, funcBody, context, clang::CFG::BuildOptions());
for(CFG::const_iterator it = sourceCFG->begin(), ei = sourceCFG->end(); it != ei; ++it){
const CFGBlock* block = *it;
for(CFGBlock::const_iterator bi = block->begin(), be = block->end(); bi != be; ++bi){
const CFGElement &elem = *bi;
const Stmt *stmt_tmp = elem.castAs<CFGStmt>().getStmt();
/*I want to get DeclRefExpr from next*/
}
}
}
}
}
};

iOS MFI controller connection issue

i have this code that is a Plugin for Unreal Engine 4 is to allow MFI game controllers (Physical Bluetooth Gamepad, Joystick) to be used in my game on iOS devices
the plugin works fine if the game (App) is launched before connecting the controller
the problem is if the game controller is connected before launching the game the game crashes after the splash screen
also disconnecting the controller whilst the game is running closes/crashes the game
any advice is much appreciated
#include "IOSInputInterfacePrivatePCH.h"
#include "IInputInterface.h"
#include "IOSGamepad.h"
/** Beginning of FGCControllerNotificationHandler class */
#if PLATFORM_IOS
#interface FGCControllerNotificationHandler : NSObject
#property FIOSGamepad* device;
+ (id)sharedInstance;
#end
#implementation FGCControllerNotificationHandler
#synthesize device;
- (id)init
{
self = [super init];
return self;
}
+ (id)alloc
{
return [super allocWithZone:NULL];
}
+ (id)allocWithZone:(NSZone *)zone {
return [[self sharedInstance] retain];
}
- (id)copyWithZone:(NSZone *)zone {
return self;
}
- (id)retain {
return self;
}
- (NSUInteger)retainCount {
return NSUIntegerMax; /** denotes an object that cannot be released */
}
- (oneway void)release {
/** never release */
}
- (id)autorelease {
return self;
}
- (void)dealloc {
[super dealloc];
}
+ (FGCControllerNotificationHandler *)sharedInstance
{
static FGCControllerNotificationHandler* instance;
#synchronized(self)
{
if (instance == nil)
{
instance = [[self alloc] init];
}
}
return instance;
}
- (void)registerObservers:(FIOSGamepad *)inDevice
{
self.device = inDevice;
NSNotificationCenter* center = [NSNotificationCenter defaultCenter];
/** Assign controller when connected */
[center addObserver:self
selector:#selector(setupControllers)
name:GCControllerDidConnectNotification
object:nil];
/** Do something after controller disconnection */
[center addObserver:self
selector:#selector(cleanControllers)
name:GCControllerDidDisconnectNotification
object:nil];
/** Search for another controller */
[GCController startWirelessControllerDiscoveryWithCompletionHandler:nil];
/** Assign controller id for known controllers */
if ([[GCController controllers] count] > 0)
{
[self setupControllers];
}
}
- (void)setupControllers
{
if(device != nil)
{
self.device->OnControllerConnected();
}
}
- (void)cleanControllers
{
if(device != nil)
{
self.device->OnControllerDisconnected();
}
}
- (int32)getControllerCount
{
return (int32)[[GCController controllers] count];
}
- (TArray<GCController *>)getConnectedControllers
{
TArray<GCController *> availableControllers;
for (GCController* c in [GCController controllers])
{
availableControllers.Add(c);
}
return availableControllers;
}
#end
#endif
/** End of FGCControllerNotificationHandler class */
/** Beginning of FIOSGamepad class */
FIOSGamepad::FIOSGamepad(const TSharedRef<FGenericApplicationMessageHandler>& InMessageHandler) :
MessageHandler(InMessageHandler)
{
#if PLATFORM_IOS
/** In the engine, all controllers map to xbox controllers for consistency */
IOSToXboxControllerMapping[0] = 0; // FaceButtonBottom
IOSToXboxControllerMapping[1] = 1; // FaceButtonRight
IOSToXboxControllerMapping[2] = 2; // FaceButtonLeft
IOSToXboxControllerMapping[3] = 3; // FaceButtonTop
IOSToXboxControllerMapping[4] = 4; // L1
IOSToXboxControllerMapping[5] = 5; // R1
IOSToXboxControllerMapping[6] = 6; // None
IOSToXboxControllerMapping[7] = 7; // None
IOSToXboxControllerMapping[8] = 8; // None
IOSToXboxControllerMapping[9] = 9; // None
IOSToXboxControllerMapping[10] = 10; // L2
IOSToXboxControllerMapping[11] = 11; // R2
IOSToXboxControllerMapping[12] = 12; // Dpad up
IOSToXboxControllerMapping[13] = 13; // Dpad down
IOSToXboxControllerMapping[14] = 14; // Dpad left
IOSToXboxControllerMapping[15] = 15; // Dpad right
IOSToXboxControllerMapping[16] = 16; // Left stick up
IOSToXboxControllerMapping[17] = 17; // Left stick down
IOSToXboxControllerMapping[18] = 18; // Left stick left
IOSToXboxControllerMapping[19] = 19; // Left stick right
IOSToXboxControllerMapping[20] = 20; // Right stick up
IOSToXboxControllerMapping[21] = 21; // Right stick down
IOSToXboxControllerMapping[22] = 22; // Right stick left
IOSToXboxControllerMapping[23] = 23; // Right stick right
Buttons[0] = FGamepadKeyNames::FaceButtonBottom;
Buttons[1] = FGamepadKeyNames::FaceButtonRight;
Buttons[2] = FGamepadKeyNames::FaceButtonLeft;
Buttons[3] = FGamepadKeyNames::FaceButtonTop;
Buttons[4] = FGamepadKeyNames::LeftShoulder;
Buttons[5] = FGamepadKeyNames::RightShoulder;
Buttons[6] = FGamepadKeyNames::SpecialRight;
Buttons[7] = FGamepadKeyNames::SpecialLeft;
Buttons[8] = FGamepadKeyNames::LeftThumb;
Buttons[9] = FGamepadKeyNames::RightThumb;
Buttons[10] = FGamepadKeyNames::LeftTriggerThreshold;
Buttons[11] = FGamepadKeyNames::RightTriggerThreshold;
Buttons[12] = FGamepadKeyNames::DPadUp;
Buttons[13] = FGamepadKeyNames::DPadDown;
Buttons[14] = FGamepadKeyNames::DPadLeft;
Buttons[15] = FGamepadKeyNames::DPadRight;
Buttons[16] = FGamepadKeyNames::LeftStickUp;
Buttons[17] = FGamepadKeyNames::LeftStickDown;
Buttons[18] = FGamepadKeyNames::LeftStickLeft;
Buttons[19] = FGamepadKeyNames::LeftStickRight;
Buttons[20] = FGamepadKeyNames::RightStickUp;
Buttons[21] = FGamepadKeyNames::RightStickDown;
Buttons[22] = FGamepadKeyNames::RightStickLeft;
Buttons[23] = FGamepadKeyNames::RightStickRight;
bNeedsControllerStateUpdate = true;
InitialButtonRepeatDelay = 0.2f;
ButtonRepeatDelay = 0.1f;
/** Initialize ControllerStates */
for (int32 ControllerIndex=0; ControllerIndex < MAX_NUM_IOS_CONTROLLERS; ++ControllerIndex)
{
FControllerState& ControllerState = ControllerStates[ControllerIndex];
FMemory::Memzero(&ControllerState, sizeof(FControllerState));
ControllerState.ControllerId = ControllerIndex;
}
[[FGCControllerNotificationHandler sharedInstance] registerObservers:this];
#endif
}
FIOSGamepad::~FIOSGamepad()
{
}
void FIOSGamepad::Tick(float DeltaTime)
{
}
void FIOSGamepad::SendControllerEvents()
{
#if PLATFORM_IOS
for (int32 ControllerIndex=0; ControllerIndex < MAX_NUM_IOS_CONTROLLERS; ++ControllerIndex)
{
FControllerState& ControllerState = ControllerStates[ControllerIndex];
if (!ControllerState.bIsConnected && bNeedsControllerStateUpdate)
{
ControllerState.bIsConnected = (ControllerIndex < ((int32) [[GCController controllers] count]));
}
if (ControllerState.bIsConnected)
{
bool CurrentStates[MAX_NUM_IOS_CONTROLLER_BUTTONS] = {0};
GCController* Controller = [GCController controllers][ControllerIndex];
if (Controller.extendedGamepad != nil)
{
GCExtendedGamepad* ExGamepad = Controller.extendedGamepad;
/** Check Analog state */
if(ControllerState.LeftXAnalog != ExGamepad.leftThumbstick.xAxis.value)
{
MessageHandler->OnControllerAnalog(FGamepadKeyNames::LeftAnalogX, ControllerState.ControllerId, ExGamepad.leftThumbstick.xAxis.value);
ControllerState.LeftXAnalog = ExGamepad.leftThumbstick.xAxis.value;
}
if(ControllerState.LeftYAnalog != ExGamepad.leftThumbstick.yAxis.value)
{
MessageHandler->OnControllerAnalog(FGamepadKeyNames::LeftAnalogY, ControllerState.ControllerId, ExGamepad.leftThumbstick.yAxis.value);
ControllerState.LeftYAnalog = ExGamepad.leftThumbstick.yAxis.value;
}
if(ControllerState.RightXAnalog != ExGamepad.rightThumbstick.xAxis.value)
{
MessageHandler->OnControllerAnalog(FGamepadKeyNames::RightAnalogX, ControllerState.ControllerId, ExGamepad.rightThumbstick.xAxis.value);
ControllerState.RightXAnalog = ExGamepad.rightThumbstick.xAxis.value;
}
if(ControllerState.RightYAnalog != ExGamepad.rightThumbstick.yAxis.value)
{
MessageHandler->OnControllerAnalog(FGamepadKeyNames::RightAnalogY, ControllerState.ControllerId, ExGamepad.rightThumbstick.yAxis.value);
ControllerState.RightYAnalog = ExGamepad.rightThumbstick.yAxis.value;
}
if(ControllerState.LeftTriggerAnalog != ExGamepad.leftTrigger.value)
{
MessageHandler->OnControllerAnalog(FGamepadKeyNames::LeftTriggerAnalog, ControllerState.ControllerId, ExGamepad.leftTrigger.value);
ControllerState.LeftTriggerAnalog = ExGamepad.leftTrigger.value;
}
if(ControllerState.RightTriggerAnalog != ExGamepad.rightTrigger.value)
{
MessageHandler->OnControllerAnalog(FGamepadKeyNames::RightTriggerAnalog, ControllerState.ControllerId, ExGamepad.rightTrigger.value);
ControllerState.RightTriggerAnalog = ExGamepad.rightTrigger.value;
}
/** Get the current state of all buttons */
CurrentStates[IOSToXboxControllerMapping[0]] = ExGamepad.buttonA.pressed;
CurrentStates[IOSToXboxControllerMapping[1]] = ExGamepad.buttonB.pressed;
CurrentStates[IOSToXboxControllerMapping[2]] = ExGamepad.buttonX.pressed;
CurrentStates[IOSToXboxControllerMapping[3]] = ExGamepad.buttonY.pressed;
CurrentStates[IOSToXboxControllerMapping[4]] = ExGamepad.leftShoulder.pressed;
CurrentStates[IOSToXboxControllerMapping[5]] = ExGamepad.rightShoulder.pressed;
CurrentStates[IOSToXboxControllerMapping[6]] = false;
CurrentStates[IOSToXboxControllerMapping[7]] = false;
CurrentStates[IOSToXboxControllerMapping[8]] = false;
CurrentStates[IOSToXboxControllerMapping[9]] = false;
CurrentStates[IOSToXboxControllerMapping[10]] = ExGamepad.leftTrigger.value > IOS_TRIGGER_THRESHOLD;
CurrentStates[IOSToXboxControllerMapping[11]] = ExGamepad.rightTrigger.value > IOS_TRIGGER_THRESHOLD;
CurrentStates[IOSToXboxControllerMapping[12]] = ExGamepad.dpad.up.pressed;
CurrentStates[IOSToXboxControllerMapping[13]] = ExGamepad.dpad.down.pressed;
CurrentStates[IOSToXboxControllerMapping[14]] = ExGamepad.dpad.left.pressed;
CurrentStates[IOSToXboxControllerMapping[15]] = ExGamepad.dpad.right.pressed;
CurrentStates[IOSToXboxControllerMapping[16]] = ExGamepad.leftThumbstick.up;
CurrentStates[IOSToXboxControllerMapping[17]] = ExGamepad.leftThumbstick.down;
CurrentStates[IOSToXboxControllerMapping[18]] = ExGamepad.leftThumbstick.left;
CurrentStates[IOSToXboxControllerMapping[19]] = ExGamepad.leftThumbstick.right;
CurrentStates[IOSToXboxControllerMapping[20]] = ExGamepad.rightThumbstick.up;
CurrentStates[IOSToXboxControllerMapping[21]] = ExGamepad.rightThumbstick.down;
CurrentStates[IOSToXboxControllerMapping[22]] = ExGamepad.rightThumbstick.left;
CurrentStates[IOSToXboxControllerMapping[23]] = ExGamepad.rightThumbstick.right;
}
else if (Controller.gamepad != nil)
{
GCGamepad* Gamepad = Controller.gamepad;
/** Get the current state of all buttons */
CurrentStates[IOSToXboxControllerMapping[0]] = Gamepad.buttonA.pressed;
CurrentStates[IOSToXboxControllerMapping[1]] = Gamepad.buttonB.pressed;
CurrentStates[IOSToXboxControllerMapping[2]] = Gamepad.buttonX.pressed;
CurrentStates[IOSToXboxControllerMapping[3]] = Gamepad.buttonY.pressed;
CurrentStates[IOSToXboxControllerMapping[4]] = Gamepad.leftShoulder.pressed;
CurrentStates[IOSToXboxControllerMapping[5]] = Gamepad.rightShoulder.pressed;
CurrentStates[IOSToXboxControllerMapping[6]] = false;
CurrentStates[IOSToXboxControllerMapping[7]] = false;
CurrentStates[IOSToXboxControllerMapping[8]] = false;
CurrentStates[IOSToXboxControllerMapping[9]] = false;
CurrentStates[IOSToXboxControllerMapping[10]] = false;
CurrentStates[IOSToXboxControllerMapping[11]] = false;
CurrentStates[IOSToXboxControllerMapping[12]] = Gamepad.dpad.up.pressed;
CurrentStates[IOSToXboxControllerMapping[13]] = Gamepad.dpad.down.pressed;
CurrentStates[IOSToXboxControllerMapping[14]] = Gamepad.dpad.left.pressed;
CurrentStates[IOSToXboxControllerMapping[15]] = Gamepad.dpad.right.pressed;
CurrentStates[IOSToXboxControllerMapping[16]] = false;
CurrentStates[IOSToXboxControllerMapping[17]] = false;
CurrentStates[IOSToXboxControllerMapping[18]] = false;
CurrentStates[IOSToXboxControllerMapping[19]] = false;
CurrentStates[IOSToXboxControllerMapping[20]] = false;
CurrentStates[IOSToXboxControllerMapping[21]] = false;
CurrentStates[IOSToXboxControllerMapping[22]] = false;
CurrentStates[IOSToXboxControllerMapping[23]] = false;
}
const double CurrentTime = FPlatformTime::Seconds();
/** For each button check against the previous state and send the correct message if any */
for (int32 ButtonIndex = 0; ButtonIndex < MAX_NUM_IOS_CONTROLLER_BUTTONS; ++ButtonIndex)
{
if(CurrentStates[ButtonIndex] != ControllerState.ButtonStates[ButtonIndex])
{
if(CurrentStates[ButtonIndex])
{
MessageHandler->OnControllerButtonPressed(Buttons[ButtonIndex], ControllerState.ControllerId, false);
}
else
{
MessageHandler->OnControllerButtonReleased(Buttons[ButtonIndex], ControllerState.ControllerId, false);
}
if(CurrentStates[ButtonIndex] == true)
{
/** this button was pressed - set the button's NextRepeatTime to the InitialButtonRepeatDelay */
ControllerState.NextRepeatTime[ButtonIndex] = CurrentTime + InitialButtonRepeatDelay;
}
}
else if(CurrentStates[ButtonIndex] == true && ControllerState.NextRepeatTime[ButtonIndex] <= CurrentTime)
{
MessageHandler->OnControllerButtonPressed(Buttons[ButtonIndex], ControllerState.ControllerId, true);
/** set the button's NextRepeatTime to the ButtonRepeatDelay */
ControllerState.NextRepeatTime[ButtonIndex] = CurrentTime + ButtonRepeatDelay;
}
/** Update the state for next time */
ControllerState.ButtonStates[ButtonIndex] = CurrentStates[ButtonIndex];
}
}
}
bNeedsControllerStateUpdate = false;
#endif
}
void FIOSGamepad::SetMessageHandler(const TSharedRef<FGenericApplicationMessageHandler>&InMessageHandler)
{
MessageHandler = InMessageHandler;
}
bool FIOSGamepad::Exec(UWorld* InWorld, const TCHAR* Cmd, FOutputDevice& Ar)
{
return false;
}
void FIOSGamepad::SetChannelValue (int32 ControllerId, FForceFeedbackChannelType ChannelType, float Value)
{
}
void FIOSGamepad::SetChannelValues (int32 ControllerId, const FForceFeedbackValues &values)
{
}
void FIOSGamepad::OnControllerConnected ()
{
for(int32 ControllerIndex=0; ControllerIndex < FMath::Min<int32>(MAX_NUM_IOS_CONTROLLERS, [[GCController controllers] count]); ++ControllerIndex)
{
[GCController controllers][ControllerIndex].playerIndex = (GCControllerPlayerIndex)ControllerIndex;
}
this->bNeedsControllerStateUpdate = true;
}
void FIOSGamepad::OnControllerDisconnected ()
{
this->bNeedsControllerStateUpdate = true;
}
/** End of FIOSGamepad class */

Change colors in devexpress charts

I am drawing a pie chart using Devexpress in my MVC project.
While doing it by default my chart generated with three colors, as below
but my client is not satisfied, with the colors of it and wanted me to change them which match with our application background, so please help me, how to do this.
Thanks in advance.
Here is my code.
settings.Name = "chart";
settings.Width = 600;
settings.Height = 250;
settings.BorderOptions.Visible = false;
Series series1 = new Series("Type", DevExpress.XtraCharts.ViewType.Pie3D);
settings.Series.Add(series1);
series1.ArgumentScaleType = ScaleType.Qualitative;
series1.ArgumentDataMember = "ClassName";
series1.ValueScaleType = ScaleType.Numerical;
series1.ValueDataMembers.AddRange(new string[] { "PercentageValues" });
series1.LegendPointOptions.PointView = PointView.ArgumentAndValues;
series1.LegendPointOptions.ValueNumericOptions.Format = NumericFormat.Percent;
series1.LegendPointOptions.ValueNumericOptions.Precision = 0;
series1.Label.ResolveOverlappingMode = ResolveOverlappingMode.Default;
series1.Label.Visible = false;
Please refer the following code. I have successfully implemented the same for giving custom color for rangebar. I guess it will work for your case also
settings.CustomDrawSeriesPoint = (s, ev) =>
{
BarDrawOptions drawOptions = ev.SeriesDrawOptions as BarDrawOptions;
if (drawOptions == null)
return;
Color colorInTarget = Color.Blue;
double x = ev.SeriesPoint.Values[0];
double y = ev.SeriesPoint.Values[1];
if (x == 0)
{ //Do starting
colorInTarget = Color.FromArgb(159,125, 189);
}
else{
//Red - price Increase
// Green price Decrease
if (y > previousYValue)
{
colorInTarget = Color.Red; ;
}
else
{
colorInTarget = Color.Green;
}
}
previousYValue = y;
drawOptions.Color = colorInTarget;
drawOptions.FillStyle.FillMode = FillMode.Solid;
drawOptions.Border.Color = Color.Transparent;
};
you can set the theme and palette properties of the chart control. follow the links below to devexpress documentation. although the examples refers to winform application they are still avaliable in asp.net mvc controls.
http://documentation.devexpress.com/#WindowsForms/CustomDocument7433
http://documentation.devexpress.com/#WindowsForms/CustomDocument5538
// Define the chart's appearance and palette.
barChart.AppearanceName = "Dark";
barChart.PaletteName = "Opulent";
private List<StudentClass.ChartsPointsSummary> GetStudentSummaryResults()
{
var StudentId = Convert.ToInt32(Request.Params["StudentID"]);
var StudentDetailsP = CtxSM.SMISGet_StudentAttendanceDetailsByStudentId(StudentId, SessionDataManager.SessionData.LoginUserId, SessionDataManager.SessionData.AcademicYearID, SessionDataManager.SessionData.BusinessUnitId, ref outError).ToList();
var Presents = StudentDetailsP.Select(p => new { p.Months, p.Presents});
var CountsP = StudentDetailsP.Count();
List<StudentClass.ChartsPointsSummary> MT = new List<StudentClass.ChartsPointsSummary>();
foreach (var ab in Presents)
{
MT.Add(new StudentClass.ChartsPointsSummary { PresentSummaryX = ab.Months, PresentSummaryY = Convert.ToInt32(ab.Presents) });
}
var StudentDetailsA = CtxSM.SMISGet_StudentAttendanceDetailsByStudentId(StudentId, SessionDataManager.SessionData.LoginUserId, SessionDataManager.SessionData.AcademicYearID, SessionDataManager.SessionData.BusinessUnitId, ref outError).ToList();
var Absents = StudentDetailsP.Select(p => new { p.Months, p.Absents });
var CountsA = StudentDetailsA.Count();
foreach (var ab in Absents)
{
MT.Add(new StudentClass.ChartsPointsSummary { AbsentSummaryX = ab.Months, AbsentSummaryY = Convert.ToInt32(ab.Absents) });
}
var StudentDetailsL = CtxSM.SMISGet_StudentAttendanceDetailsByStudentId(StudentId, SessionDataManager.SessionData.LoginUserId, SessionDataManager.SessionData.AcademicYearID, SessionDataManager.SessionData.BusinessUnitId, ref outError).ToList();
var CountL = StudentDetailsL.Count();
var Leaves = StudentDetailsP.Select(p => new { p.Months, p.Leaves });
foreach (var ab in Leaves)
{
MT.Add(new StudentClass.ChartsPointsSummary { LeaveSummaryX = ab.Months, LeaveSummaryY = Convert.ToInt32(ab.Leaves) });
}
return MT;
}
#Html.DevExpress().Chart(settings =>
{
settings.Name = "SummaryDetailsById";
settings.Width = 1032;
settings.Height = 250;
Series chartSeries = new Series("Presents", DevExpress.XtraCharts.ViewType.Bar);
chartSeries.ArgumentDataMember = "PresentSummaryX";
chartSeries.ValueDataMembers[0] = "PresentSummaryY";
settings.Series.Add(chartSeries);
Series chartSeries2 = new Series("Absents", DevExpress.XtraCharts.ViewType.Bar);
chartSeries2.ArgumentDataMember = "AbsentSummaryX";
chartSeries2.ValueDataMembers[0] = "AbsentSummaryY";
settings.Series.Add(chartSeries2);
Series chartSeries3 = new Series("Leaves", DevExpress.XtraCharts.ViewType.Bar);
chartSeries3.ArgumentDataMember = "LeaveSummaryX";
chartSeries3.ValueDataMembers[0] = "LeaveSummaryY";
settings.Series.Add(chartSeries3);
settings.CrosshairEnabled = DefaultBoolean.Default;
settings.BackColor = System.Drawing.Color.Transparent;
settings.BorderOptions.Visibility = DefaultBoolean.True;
settings.Titles.Add(new ChartTitle()
{
Text = "Student Attendance Summary"
});
XYDiagram diagram = ((XYDiagram)settings.Diagram);
diagram.AxisX.Label.Angle = -30;
diagram.AxisY.Interlaced = true;
}).Bind(Model).GetHtml()

Actionscript3 ArgumentError: Error #2109:

Making a touch based platform game based in actionscript 3 using Gary Rosenzweig's game as a basis, all was going well until today, I've been trying to swap out floor objects etc without changing much of the actionscript at all and I have the following error.
ArgumentError: Error #2109: Frame label jump not found in scene jump.
at flash.display::MovieClip/gotoAndStop()
at PlatformGame/moveCharacter()[C:\Users\Michael\Desktop\platformGame\PlatformGame.as:418]
at PlatformGame/moveEnemies()[C:\Users\Michael\Desktop\platformGame\PlatformGame.as:314]
at PlatformGame/gameLoop()[C:\Users\Michael\Desktop\platformGame\PlatformGame.as:303]
This also seems to cause problems with collision detection.
The code is as follows. (not i have not changed the scene or label names from the originals but it still shows the error).
package {
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.utils.getTimer;
import flash.ui.Multitouch;
import flash.ui.MultitouchInputMode;
public class PlatformGame extends MovieClip {
// movement constants
static const gravity:Number = .004;
// screen constants
static const edgeDistance:Number = 100;
public var rightButton:SimpleButton;
// object arrays
private var fixedObjects:Array;
private var otherObjects:Array;
// hero and enemies
private var hero:Object;
private var enemies:Array;
// game state
private var playerObjects:Array;
private var gameScore:int;
private var gameMode:String = "start";
private var playerLives:int;
private var lastTime:Number = 0;
// start game
public function startPlatformGame() {
playerObjects = new Array();
gameScore = 0;
gameMode = "play";
playerLives = 3;
}
// start level
public function startGameLevel() {
// create characters
createHero();
addEnemies();
// examine level and note all objects
examineLevel();
// add listeners
this.addEventListener(Event.ENTER_FRAME,gameLoop);
Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;
gamelevel["rButton"].addEventListener(TouchEvent.TOUCH_BEGIN,touchRight);
gamelevel["rButton"].addEventListener(TouchEvent.TOUCH_END,touchRightReleased);
gamelevel["lButton"].addEventListener(TouchEvent.TOUCH_BEGIN,touchLeft);
gamelevel["lButton"].addEventListener(TouchEvent.TOUCH_END,touchLeftReleased);
gamelevel["jButton"].addEventListener(TouchEvent.TOUCH_BEGIN,jump);
gamelevel["jButton"].addEventListener(TouchEvent.TOUCH_END,jumpReleased);
trace("hi"+gamelevel["rButton"]);
// set game state
gameMode = "play";
addScore(0);
showLives();
}
// start level
public function startGameLevelHarder() {
// create characters
createHero();
addHardEnemies();
// examine level and note all objects
examineLevel();
// set game state
gameMode = "play";
addScore(0);
showLives();
}
// start level
public function startGameLevelHardest() {
// create characters
createHero();
addHardestEnemies();
// examine level and note all objects
examineLevel();
// set game state
gameMode = "play";
addScore(0);
showLives();
}
// creates the hero object and sets all properties
public function createHero() {
hero = new Object();
hero.mc = gamelevel.hero;
hero.dx = 0.0;
hero.dy = 0.0;
hero.inAir = false;
hero.direction = 0;
hero.animstate = "stand";
hero.walkAnimation = new Array(2,3,4,5,6,7,8);
hero.animstep = 0;
hero.jump = false;
hero.moveLeft = false;
hero.moveRight = false;
hero.jumpSpeed = .8;
hero.walkSpeed = .15;
hero.width = 15.0;
hero.height = 35.0;
hero.startx = hero.mc.x;
hero.starty = hero.mc.y;
}
// finds all enemies in the level and creates an object for each
public function addEnemies() {
enemies = new Array();
var i:int = 1;
while (true) {
if (gamelevel["enemy"+i] == null) break;
var enemy = new Object();
enemy.mc = gamelevel["enemy"+i];
enemy.dx = 0.0;
enemy.dy = 0.0;
enemy.inAir = false;
enemy.direction = 1;
enemy.animstate = "stand"
enemy.walkAnimation = new Array(2,3,4,5);
enemy.animstep = 0;
enemy.jump = false;
enemy.moveRight = true;
enemy.moveLeft = false;
enemy.jumpSpeed = 1.0;
enemy.walkSpeed = .08;
enemy.width = 30.0;
enemy.height = 30.0;
enemies.push(enemy);
i++;
}
}
// finds all enemies in the level and creates an object for each
public function addHardEnemies() {
enemies = new Array();
var i:int = 1;
while (true) {
if (gamelevel["enemy"+i] == null) break;
var enemy = new Object();
enemy.mc = gamelevel["enemy"+i];
enemy.dx = 0.0;
enemy.dy = 0.0;
enemy.inAir = false;
enemy.direction = 1;
enemy.animstate = "stand"
enemy.walkAnimation = new Array(2,3,4,5);
enemy.animstep = 0;
enemy.jump = false;
enemy.moveRight = true;
enemy.moveLeft = false;
enemy.jumpSpeed = 1.0;
enemy.walkSpeed = .15;
enemy.width = 56.0;
enemy.height = 80.0;
enemies.push(enemy);
i++;
}
}
// finds all enemies in the level and creates an object for each
public function addHardestEnemies() {
enemies = new Array();
var i:int = 1;
while (true) {
if (gamelevel["enemy"+i] == null) break;
var enemy = new Object();
enemy.mc = gamelevel["enemy"+i];
enemy.dx = 0.0;
enemy.dy = 0.0;
enemy.inAir = false;
enemy.direction = 1;
enemy.animstate = "stand"
enemy.walkAnimation = new Array(2,3,4,5);
enemy.animstep = 0;
enemy.jump = false;
enemy.moveRight = true;
enemy.moveLeft = false;
enemy.jumpSpeed = 1.0;
enemy.walkSpeed = .25;
enemy.width = 40.0;
enemy.height = 40.0;
enemies.push(enemy);
i++;
}
}
// look at all level children and note walls, floors and items
public function examineLevel() {
fixedObjects = new Array();
otherObjects = new Array();
for(var i:int=0;i<this.gamelevel.numChildren;i++) {
var mc = this.gamelevel.getChildAt(i);
// add floors and walls to fixedObjects
if ((mc is Floor) || (mc is Wall) || (mc is ground1) || (mc is wall1) || (mc is ledge1) || (mc is ledge2) || (mc is rock) ||(mc is rocktip)) {
var floorObject:Object = new Object();
floorObject.mc = mc;
floorObject.leftside = mc.x;
floorObject.rightside = mc.x+mc.width;
floorObject.topside = mc.y;
floorObject.bottomside = mc.y+mc.height;
fixedObjects.push(floorObject);
// add treasure, key and door to otherOjects
} else if ((mc is Treasure) || (mc is Key) || (mc is Door) || (mc is Chest)) {
otherObjects.push(mc);
}
}
}
// note key presses, set hero properties
public function touchRight(event:TouchEvent) {
trace("touchRight");
hero.moveRight = true;
}
public function touchRightReleased(event:TouchEvent) {
hero.moveRight = false;
}
public function touchLeft(event:TouchEvent) {
hero.moveLeft = true;
}
public function touchLeftReleased(event:TouchEvent) {
hero.moveLeft = false;
}
public function jump(event:TouchEvent) {
if (!hero.inAir) {
hero.jump = true;
}
}
public function jumpReleased(event:TouchEvent) {
if (!hero.inAir) {
hero.jump = false;
}
}
// note key presses, set hero properties
//public function keyDownFunction(event:KeyboardEvent) {
//if (gameMode != "play") return; // don't move until in play mode
//if (event.keyCode == 37) {
//hero.moveLeft = true;
//} else if (event.keyCode == 39) {
//hero.moveRight = true;
//} else if (event.keyCode == 32) {
//if (!hero.inAir) {
//hero.jump = true;
//}
//}
//}
//public function keyUpFunction(event:KeyboardEvent) {
//if (event.keyCode == 37) {
//hero.moveLeft = false;
//} else if (event.keyCode == 39) {
//hero.moveRight = false;
//}
//}
// perform all game tasks
public function gameLoop(event:Event) {
// get time differentce
if (lastTime == 0) lastTime = getTimer();
var timeDiff:int = getTimer()-lastTime;
lastTime += timeDiff;
// only perform tasks if in play mode
if (gameMode == "play") {
moveCharacter(hero,timeDiff);
moveEnemies(timeDiff);
checkCollisions();
scrollWithHero();
}
}
// loop through all enemies and move them
public function moveEnemies(timeDiff:int) {
for(var i:int=0;i<enemies.length;i++) {
// move
moveCharacter(enemies[i],timeDiff);
// if hit a wall, turn around
if (enemies[i].hitWallRight) {
enemies[i].moveLeft = true;
enemies[i].moveRight = false;
} else if (enemies[i].hitWallLeft) {
enemies[i].moveLeft = false;
enemies[i].moveRight = true;
}
}
}
// primary function for character movement
public function moveCharacter(char:Object,timeDiff:Number) {
if (timeDiff < 1) return;
// assume character pulled down by gravity
var verticalChange:Number = char.dy*timeDiff + timeDiff*gravity;
if (verticalChange > 15.0) verticalChange = 15.0;
char.dy += timeDiff*gravity;
// react to changes from key presses
var horizontalChange = 0;
var newAnimState:String = "stand";
var newDirection:int = char.direction;
if (char.moveLeft) {
// walk left
horizontalChange = -char.walkSpeed*timeDiff;
newAnimState = "walk";
newDirection = -1;
} else if (char.moveRight) {
// walk right
horizontalChange = char.walkSpeed*timeDiff;
newAnimState = "walk";
newDirection = 1;
}
if (char.jump) {
// start jump
char.jump = false;
char.dy = -char.jumpSpeed;
verticalChange = -char.jumpSpeed;
newAnimState = "jump";
}
// assume no wall hit, and hanging in air
char.hitWallRight = false;
char.hitWallLeft = false;
char.inAir = true;
// find new vertical position
var newY:Number = char.mc.y + verticalChange;
// loop through all fixed objects to see if character has landed
for(var i:int=0;i<fixedObjects.length;i++) {
if ((char.mc.x+char.width/2 > fixedObjects[i].leftside) && (char.mc.x-char.width/2 < fixedObjects[i].rightside)) {
if ((char.mc.y <= fixedObjects[i].topside) && (newY > fixedObjects[i].topside)) {
newY = fixedObjects[i].topside;
char.dy = 0;
char.inAir = false;
break;
}
}
}
// find new horizontal position
var newX:Number = char.mc.x + horizontalChange;
// loop through all objects to see if character has bumped into a wall
for(i=0;i<fixedObjects.length;i++) {
if ((newY > fixedObjects[i].topside) && (newY-char.height < fixedObjects[i].bottomside)) {
if ((char.mc.x-char.width/2 >= fixedObjects[i].rightside) && (newX-char.width/2 <= fixedObjects[i].rightside)) {
newX = fixedObjects[i].rightside+char.width/2;
char.hitWallLeft = true;
break;
}
if ((char.mc.x+char.width/2 <= fixedObjects[i].leftside) && (newX+char.width/2 >= fixedObjects[i].leftside)) {
newX = fixedObjects[i].leftside-char.width/2;
char.hitWallRight = true;
break;
}
}
}
// set position of character
char.mc.x = newX;
char.mc.y = newY;
// set animation state
if (char.inAir) {
newAnimState = "";
}
char.animstate = newAnimState;
// move along walk cycle
if (char.animstate == "walk") {
char.animstep += timeDiff/60;
if (char.animstep > char.walkAnimation.length) {
char.animstep = 0;
}
char.mc.gotoAndStop(char.walkAnimation[Math.floor(char.animstep)]);
// not walking, show stand or jump state
} else {
char.mc.gotoAndStop(char.animstate);
}
// changed directions
if (newDirection != char.direction) {
char.direction = newDirection;
char.mc.scaleX = char.direction*1.35;
}
}
// scroll to the right or left if needed
public function scrollWithHero() {
var stagePosition:Number = gamelevel.x+hero.mc.x;
var rightEdge:Number = stage.stageWidth-edgeDistance;
var leftEdge:Number = edgeDistance;
if (stagePosition > rightEdge) {
gamelevel.x -= (stagePosition-rightEdge);
gamelevel["rButton"].x += (stagePosition-rightEdge);
gamelevel["lButton"].x += (stagePosition-rightEdge);
gamelevel["jButton"].x += (stagePosition-rightEdge);
if (gamelevel.x < -(gamelevel.width-stage.stageWidth)) gamelevel.x = -(gamelevel.width-stage.stageWidth);
}
if (stagePosition < leftEdge) {
gamelevel.x += (leftEdge-stagePosition);
gamelevel["rButton"].x -= (leftEdge-stagePosition);
gamelevel["lButton"].x -= (leftEdge-stagePosition);
gamelevel["jButton"].x -= (leftEdge-stagePosition);
if (gamelevel.x > 0) gamelevel.x = 0;
}
}
// check collisions with enemies, items
public function checkCollisions() {
// enemies
for(var i:int=enemies.length-1;i>=0;i--) {
if (hero.mc.hitTestObject(enemies[i].mc)) {
// is the hero jumping down onto the enemy?
if (hero.inAir && (hero.dy > 0)) {
enemyDie(i);
} else {
heroDie();
}
}
}
// items
for(i=otherObjects.length-1;i>=0;i--) {
if (hero.mc.hitTestObject(otherObjects[i])) {
getObject(i);
}
}
}
// remove enemy
public function enemyDie(enemyNum:int) {
var pb:PointBurst = new PointBurst(gamelevel,"Got Em!",enemies[enemyNum].mc.x,enemies[enemyNum].mc.y-20);
gamelevel.removeChild(enemies[enemyNum].mc);
enemies.splice(enemyNum,1);
}
// enemy got player
public function heroDie() {
// show dialog box
var dialog:Dialog = new Dialog();
dialog.x = 175;
dialog.y = 100;
addChild(dialog);
if (playerLives == 0) {
gameMode = "gameover";
dialog.message.text = "Game Over!";
} else {
gameMode = "dead";
dialog.message.text = "He Got You!";
playerLives--;
}
hero.mc.gotoAndPlay("die");
}
// player collides with objects
public function getObject(objectNum:int) {
// award points for treasure
if (otherObjects[objectNum] is Treasure) {
var pb:PointBurst = new PointBurst(gamelevel,100,otherObjects[objectNum].x,otherObjects[objectNum].y);
gamelevel.removeChild(otherObjects[objectNum]);
otherObjects.splice(objectNum,1);
addScore(100);
// got the key, add to inventory
} else if (otherObjects[objectNum] is Key) {
pb = new PointBurst(gamelevel,"Got Key!" ,otherObjects[objectNum].x,otherObjects[objectNum].y);
playerObjects.push("Key");
gamelevel.removeChild(otherObjects[objectNum]);
otherObjects.splice(objectNum,1);
// hit the door, end level if hero has the key
} else if (otherObjects[objectNum] is Door) {
if (playerObjects.indexOf("Key") == -1) return;
if (otherObjects[objectNum].currentFrame == 1) {
otherObjects[objectNum].gotoAndPlay("open");
levelComplete();
}
// got the chest, game won
} else if (otherObjects[objectNum] is Chest) {
otherObjects[objectNum].gotoAndStop("open");
gameComplete();
}
}
// add points to score
public function addScore(numPoints:int) {
gameScore += numPoints;
scoreDisplay.text = String(gameScore);
}
// update player lives
public function showLives() {
livesDisplay.text = String(playerLives);
}
// level over, bring up dialog
public function levelComplete() {
gameMode = "done";
var dialog:Dialog = new Dialog();
dialog.x = 175;
dialog.y = 100;
addChild(dialog);
dialog.message.text = "Level Complete!";
}
// game over, bring up dialog
public function gameComplete() {
gameMode = "gameover";
var dialog:Dialog = new Dialog();
dialog.x = 175;
dialog.y = 100;
addChild(dialog);
dialog.message.text = "You Got the Treasure!";
}
// dialog button clicked
public function clickDialogButton(event:MouseEvent) {
removeChild(MovieClip(event.currentTarget.parent));
// new life, restart, or go to next level
if (gameMode == "dead") {
// reset hero
showLives();
hero.mc.x = hero.startx;
hero.mc.y = hero.starty;
gameMode = "play";
} else if (gameMode == "gameover") {
cleanUp();
gotoAndStop("start");
} else if (gameMode == "done") {
cleanUp();
nextFrame();
}
// give stage back the keyboard focus
stage.focus = stage;
}
// clean up game
public function cleanUp() {
removeChild(gamelevel);
this.removeEventListener(Event.ENTER_FRAME,gameLoop);
}
}
}
The error is with the following line and is occurring because the referenced MovieClip does not have a frame labelled "jump":
char.mc.gotoAndStop(char.animstate);
My guess is that you made a change to the MovieClip which contains your character and, in doing so, removed the label which the code above references.

OOXML : keep images displayed after moving the header content to to the body

I am using open XML SDK and I want to move the content of content control (containing images) from the header to the body, the problem that images does not show after moving. After copying the content control content I am adding the image parts in this way :
foreach (var headerPart in wordDocument.MainDocumentPart.HeaderParts)
{
SdtBlock sdtToSave = this.FindSdtBlock(contentControlTag, headerPart );
if (sdtToSave != null)
{
foreach (var imagePart in headerPart.ImageParts)
{
ImagePart newPart = mainPart.AddImagePart(imagePart.ContentType);
this.GenerateImagePartContent(newPart, imagePart.GetStream()); }
}
}
private void GenerateImagePartContent(ImagePart imagePart, Stream partStream)
{
imagePart.FeedData(partStream);
partStream.Close();
}
then if I add this lines :
Paragraph paragraph = sdtToSave.SdtContentBlock.GetFirstChild<Paragraph>();
Run run = new Run();
paragraph.Append(run);
run.Append(this.GenerateDrawing(mainPart.GetIdOfPart(newPart)));
private Drawing GenerateDrawing(String relationshipID)
{
Drawing drawing1 = new Drawing();
Inline inline1 = new Inline() { DistanceFromTop = (UInt32Value)0U, DistanceFromBottom = (UInt32Value)0U, DistanceFromLeft = (UInt32Value)0U, DistanceFromRight = (UInt32Value)0U };
Extent extent1 = new Extent() { Cx = 152400L, Cy = 152400L };
EffectExtent effectExtent1 = new EffectExtent() { LeftEdge = 0L, TopEdge = 0L, RightEdge = 0L, BottomEdge = 0L };
DocProperties docProperties1 = new DocProperties() { Id = (UInt32Value)1U, Name = "Image 1" };
NonVisualGraphicFrameDrawingProperties nonVisualGraphicFrameDrawingProperties1 = new NonVisualGraphicFrameDrawingProperties();
A.GraphicFrameLocks graphicFrameLocks1 = new A.GraphicFrameLocks() { NoChangeAspect = true };
graphicFrameLocks1.AddNamespaceDeclaration("a", "http://schemas.openxmlformats.org/drawingml/2006/main");
nonVisualGraphicFrameDrawingProperties1.Append(graphicFrameLocks1);
A.Graphic graphic1 = new A.Graphic();
graphic1.AddNamespaceDeclaration("a", "http://schemas.openxmlformats.org/drawingml/2006/main");
A.GraphicData graphicData1 = new A.GraphicData() { Uri = "http://schemas.openxmlformats.org/drawingml/2006/picture" };
Pic.Picture picture1 = new Pic.Picture();
picture1.AddNamespaceDeclaration("pic", "http://schemas.openxmlformats.org/drawingml/2006/picture");
Pic.NonVisualPictureProperties nonVisualPictureProperties1 = new Pic.NonVisualPictureProperties();
Pic.NonVisualDrawingProperties nonVisualDrawingProperties1 = new Pic.NonVisualDrawingProperties() { Id = (UInt32Value)0U, Name = "AddTo_Blink.png" };
Pic.NonVisualPictureDrawingProperties nonVisualPictureDrawingProperties1 = new Pic.NonVisualPictureDrawingProperties();
nonVisualPictureProperties1.Append(nonVisualDrawingProperties1);
nonVisualPictureProperties1.Append(nonVisualPictureDrawingProperties1);
Pic.BlipFill blipFill1 = new Pic.BlipFill();
A.Blip blip1 = new A.Blip() { Embed = relationshipID };
A.BlipExtensionList blipExtensionList1 = new A.BlipExtensionList();
A.BlipExtension blipExtension1 = new A.BlipExtension() { Uri = "{28A0092B-C50C-407E-A947-70E740481C1C}" };
A14.UseLocalDpi useLocalDpi1 = new A14.UseLocalDpi() { Val = false };
useLocalDpi1.AddNamespaceDeclaration("a14", "http://schemas.microsoft.com/office/drawing/2010/main");
blipExtension1.Append(useLocalDpi1);
blipExtensionList1.Append(blipExtension1);
blip1.Append(blipExtensionList1);
A.Stretch stretch1 = new A.Stretch();
A.FillRectangle fillRectangle1 = new A.FillRectangle();
stretch1.Append(fillRectangle1);
blipFill1.Append(blip1);
blipFill1.Append(stretch1);
Pic.ShapeProperties shapeProperties1 = new Pic.ShapeProperties();
A.Transform2D transform2D1 = new A.Transform2D();
A.Offset offset1 = new A.Offset() { X = 0L, Y = 0L };
A.Extents extents1 = new A.Extents() { Cx = 152400L, Cy = 152400L };
transform2D1.Append(offset1);
transform2D1.Append(extents1);
A.PresetGeometry presetGeometry1 = new A.PresetGeometry() { Preset = A.ShapeTypeValues.Rectangle };
A.AdjustValueList adjustValueList1 = new A.AdjustValueList();
presetGeometry1.Append(adjustValueList1);
shapeProperties1.Append(transform2D1);
shapeProperties1.Append(presetGeometry1);
picture1.Append(nonVisualPictureProperties1);
picture1.Append(blipFill1);
picture1.Append(shapeProperties1);
graphicData1.Append(picture1);
graphic1.Append(graphicData1);
inline1.Append(extent1);
inline1.Append(effectExtent1);
inline1.Append(docProperties1);
inline1.Append(nonVisualGraphicFrameDrawingProperties1);
inline1.Append(graphic1);
drawing1.Append(inline1);
return drawing1;
}
all images are shown at the end of body.
From the OXML SDK productivity tool I can see that bookmarks are used to insert images inside a paragraph.
To summarize, I want to know how to keep images when moving content controls from header to the body.
Regards.
When you add your image part to the mainPart, it will be given a relId which is unlikely to be the same as the relId it had in the headerPart. So you'll have to adjust the relId in the drawing (Embed = relationshipID) to match.

Resources