Example #1
0
Item::e_sercode Item::deserialize_function( Stream *file, VMachine *vm )
{
   if ( vm == 0 )
      return sc_missvm;

   Symbol *sym;
   LiveModule *lmod;

   e_sercode sc = deserialize_symbol( file, vm, &sym, &lmod );
   if ( sc != sc_ok  )
      return sc;

   // read the function called status

   if ( ! sym->isFunction() ) {
      // external function
      setFunction( new CoreFunc( sym, lmod ) );
      return sc_ok;
   }

   // internal function.
   FuncDef *def = sym->getFuncDef();

   // read the once status
   uint32 itemId = def->onceItemId();
   if( itemId != FuncDef::NO_STATE )
   {
      byte called;
      file->read( &called, 1 );
      if( called )
         lmod->globals()[ itemId ].setInteger( 1 );
      else
         lmod->globals()[ itemId ].setNil();
   }

   CoreFunc* function = new CoreFunc( sym, lmod );
   // read the closure state.
   uint32 closlen;
   file->read( &closlen, sizeof( closlen ) );
   if( closlen != 0 )
   {
      ItemArray* closure = new ItemArray( closlen );
      closure->resize( closlen );

      // put the state in now, so we can destroy it in case of error.
      function->closure( closure );

      // deserialize all the items.
      for( uint32 i = 0; i < closlen; i++ ) {
         Item::e_sercode res = (*closure)[i].deserialize(file, vm );
         if ( res != sc_ok )
            return res;
      }

   }

   setFunction( function );
   return sc_ok;
}
Example #2
0
bool Item::serialize_function( Stream *file, const CoreFunc *func, bool bLive ) const
{
   byte type = FLC_ITEM_FUNC;
   if ( bLive )
         type |= 0x80;
   file->write( &type, 1 );

   // we don't serialize the module ID because it is better to rebuild it on deserialization
   serialize_symbol( file, func->symbol() );

   if ( func->symbol()->isFunction() )
   {
      // language function ? -- serialize the state.
      FuncDef *fdef = func->symbol()->getFuncDef();
      // write the called status
      uint32 itemId = fdef->onceItemId();
      if ( itemId != FuncDef::NO_STATE )
      {
         byte called = func->liveModule()->globals()[ itemId ].isNil() ? 0 : 1;
         file->write( &called, 1 );
      }

      // and we may need to serialize also it's closure.
      ItemArray* closed = func->closure();
      if( closed != 0 )
      {
         int32 len = endianInt32( closed->length() );
         file->write( (byte *) &len, sizeof( len ) );

         for( uint32 i = 0; i < closed->length(); i ++ )
         {
            (*closed)[i].serialize( file, bLive );
            if( ! file->good() )
               return false;
         }
      }
      else {
         int32 len = 0;
         file->write( (byte *) &len, sizeof( len ) );
      }
   }

   if ( ! file->good() )
      return false;

   return true;
}
Example #3
0
void HighscoresList::load(const ItemArray &items, int highlight)
{
    clear();
    QListViewItem *line = 0;
    for (int j=items.nbEntries()-1; j>=0; j--) {
        QListViewItem *item = addLine(items, j, j==highlight);
        if ( j==highlight ) line = item;
    }
    if (line) ensureItemVisible(line);
}
Example #4
0
void HighscoresList::load(const ItemArray &items, int highlight)
{
//     kDebug(11001) ;
    clear();
    QTreeWidgetItem *line = 0;
    for (int j=items.nbEntries()-1; j>=0; j--) {
        QTreeWidgetItem *item = addLine(items, j, j==highlight);
        if ( j==highlight ) line = item;
    }
    scrollTo(indexFromItem(line));
}
SRCR_BEGIN_NS

////////////////////////////////////////////////////////////////////////////
// クラス

//==========================================================================
// StEmp_10201_1001_GetShield メソッド

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// 外部サービス

/*---------------------------------------------------------------------*//**
	開始
**//*---------------------------------------------------------------------*/
void StEmp_10201_1001_GetShield::begin(u32 param)
{
	MyParty* party = (MyParty*)Game::getGame()->getMyParty(); ASSERT(party != 0L);
	ItemManager* itmmng = party->getItemManager(); ASSERT(itmmng != 0L);

	// 盾入手
	ItemArray itmarr = itmmng->findByItemDefId(ItemIdDef::ITEMDID_DUMMY, true);	// 予約用ダミーの検索
	if(itmarr.getCount() > 0)
	{
		// 盾入手場所確保用のダミーアイテムを削除
		Item* item = itmarr.item(0);
		itmmng->removeItem(item->getItemGenId());
		// 盾の追加
		itmmng->newItem(ItemIdDef::ITEMDID_SHLD_FIRST, 0L, Item::F_NOEDIT, true);	// 編集不可を末尾に
		// 盾の装備
		PartnerUnit* unitPc2 = (PartnerUnit*)party->pcUnit(MyParty::PC_PTN);
		unitPc2->equipBest();
		unitPc2->updateEquipModelObjVisibility();
	}

	StEmp::begin(param);
}
Example #6
0
void ScoresList::addLineItem(const ItemArray &items,
                             uint index, QListViewItem *line)
{
    uint k = 0;
    for (uint i=0; i<items.size(); i++) {
        const ItemContainer &container = *items[i];
        if ( !container.item()->isVisible() ) continue;
        if (line) line->setText(k, itemText(container, index));
        else {
            addColumn( container.item()->label() );
            setColumnAlignment(k, container.item()->alignment());
        }
        k++;
    }
}
/*---------------------------------------------------------------------*//**
	デフォルトアイテムの追加
**//*---------------------------------------------------------------------*/
void StoryManager::setupDefaultItems()
{
	ItemManager* itmmng = ((MyParty*)Game::getGame()->getMyParty())->getItemManager();

	// 武器が無い場合
	{
		ItemArray itmarr = itmmng->findByCategory(ItemDef::CAT_WEAPON, true);
		if(itmarr.getCount() <= 0)	// 武器がない
		{
			// デフォルトのこん棒を追加
			itmmng->newItem(ItemIdDef::ITEMDID_WEP_FIRST, 0L, Item::F_NOEDIT, true);	// 編集不可で末尾に追加
		}
	}
	
	// 盾が無い場合
	{
		ItemArray itmarr = itmmng->findByCategory(ItemDef::CAT_SHIELD, true);
		if(itmarr.getCount() <= 0)	// 盾がない
		{
			itmarr = itmmng->findByItemDefId(ItemIdDef::ITEMDID_DUMMY, true);
			if(itmarr.getCount() <= 0)	// 盾入手場所確保用のダミーアイテムもない
			{
				// 盾入手場所確保用のダミーアイテムを追加
				itmmng->newItem(ItemIdDef::ITEMDID_DUMMY, 0L, Item::F_NOEDIT, true);		// 編集不可で末尾に追加
			}

			// ダミーを盾に変更
			if(_storyid >= StoryIdDef::STID_EP01_ASA__START_)
			{
				itmarr = itmmng->findByItemDefId(ItemIdDef::ITEMDID_DUMMY, true);	// 予約用ダミーの検索
				if(itmarr.getCount() > 0)
				{
					// 盾入手場所確保用のダミーアイテムを削除
					Item* item = itmarr.item(0);
					itmmng->removeItem(item->getItemGenId());
					// 盾の追加
					itmmng->newItem(ItemIdDef::ITEMDID_SHLD_FIRST, 0L, Item::F_NOEDIT, true);	// 編集不可を末尾に
				}
			}
		}
	}

	// 最強装備に
	Party* party = Game::getGame()->getMyParty(); ASSERT(party != 0L);
	PartnerUnit* unitPc2 = (PartnerUnit*)party->pcUnit(MyParty::PC_PTN);
	unitPc2->equipBest();
}
Example #8
0
void LastMultipleScoresList::addLineItem(const ItemArray &si,
                                         uint index, QTreeWidgetItem *line)
{
//   kDebug(11001) ;
    uint k = 1; // skip "id"
    for (int i=0; i<si.size()-2; i++) {
        if ( i==3 ) k = 5; // skip "date"
        const ItemContainer& container = *si[k];
        k++;
        if (line) {
	  line->setText(i, itemText(container, index));
	  line->setTextAlignment(i, container.item()->alignment());
	}
        else {
	    headerItem()->setText(i, container.item()->label() );
            headerItem()->setTextAlignment(i, container.item()->alignment());
        }
    }
}
Example #9
0
void ScoresList::addLineItem(const ItemArray &items,
                             uint index, QTreeWidgetItem *line)
{
//   kDebug(11001) ;
    uint k = 0;
    for (int i=0; i<items.size(); i++) {
        const ItemContainer& container = *items[i];
        if ( !container.item()->isVisible() ) {
	  continue;
	}
        if (line) {
	  line->setText(k, itemText(container, index));
	  line->setTextAlignment(k, container.item()->alignment());
	}
        else {
	    headerItem()->setText(k, container.item()->label() );
            headerItem()->setTextAlignment(k, container.item()->alignment());
        }
        k++;
    }
    update();
}
Example #10
0
CVirtualPad::ItemArray CVirtualPad::GetItems(float screenWidth, float screenHeight)
{
	ItemArray items;

	float uiScale = 1;
	if(screenHeight < 480)
	{
		uiScale = 1.5f;
	}
	else if(screenHeight < 768)
	{
		uiScale = 1.25f;
	}

	float analogStickSize = 96.0f / uiScale;
	float lrButtonWidth = 128.0f / uiScale;
	float lrButtonHeight = 64.0f / uiScale;
	float lr3ButtonSize = 64.0f / uiScale;
	float dpadButtonSize = 32.0f / uiScale;
	float margin = 32.0f / uiScale;
	float padButtonSize = 64.0f / uiScale;

	float dpadPosX = margin;
	float dpadPosY = screenHeight - (padButtonSize * 3) - margin;
	float actionPadPosX = screenWidth - (padButtonSize * 3) - margin;
	float actionPadPosY = screenHeight - (padButtonSize * 3) - margin;
	float startSelPadPosX = (screenWidth - (padButtonSize * 3)) / 2;
	float startSelPadPosY = screenHeight - padButtonSize - margin;
	float leftButtonsPosX = margin;
	float leftButtonsPosY = margin;
	float rightButtonsPosX = screenWidth - (margin + lrButtonWidth);
	float rightButtonsPosY = margin;
	float leftAnalogStickPosX = dpadPosX + (padButtonSize * 3) + analogStickSize;
	float rightAnalogStickPosX = actionPadPosX - (analogStickSize * 2);
	float analogStickPosY = screenHeight - (padButtonSize * 3) - margin;
	float l3ButtonPosX = startSelPadPosX - (lr3ButtonSize * 2);
	float r3ButtonPosX = startSelPadPosX + (padButtonSize * 3) + lr3ButtonSize;
	float lr3ButtonPosY = screenHeight - padButtonSize - margin;

	items.push_back(CreateButtonItem(
		leftButtonsPosX, leftButtonsPosY, leftButtonsPosX + lrButtonWidth, leftButtonsPosY + lrButtonHeight,
		PS2::CControllerInfo::L2, "lr", "L2"));
	items.push_back(CreateButtonItem(
		leftButtonsPosX, leftButtonsPosY + lrButtonHeight, leftButtonsPosX + lrButtonWidth, leftButtonsPosY + lrButtonHeight * 2,
		PS2::CControllerInfo::L1, "lr", "L1"));
	items.push_back(CreateButtonItem(
		rightButtonsPosX, rightButtonsPosY, rightButtonsPosX + lrButtonWidth, rightButtonsPosY + lrButtonHeight,
		PS2::CControllerInfo::R2, "lr", "R2"));
	items.push_back(CreateButtonItem(
		rightButtonsPosX, rightButtonsPosY + lrButtonHeight, rightButtonsPosX + lrButtonWidth, rightButtonsPosY + lrButtonHeight * 2,
		PS2::CControllerInfo::R1, "lr", "R1"));

	items.push_back(CreateButtonItem(
		startSelPadPosX + padButtonSize * 0, startSelPadPosY + padButtonSize / 2, startSelPadPosX + padButtonSize * 1, startSelPadPosY + padButtonSize,
		PS2::CControllerInfo::SELECT, "select"));
	items.push_back(CreateButtonItem(
		startSelPadPosX + padButtonSize * 2, startSelPadPosY + padButtonSize / 2, startSelPadPosX + padButtonSize * 3, startSelPadPosY + padButtonSize,
		PS2::CControllerInfo::START, "start"));

	items.push_back(CreateButtonItem(
		dpadPosX + dpadButtonSize * 2, dpadPosY + dpadButtonSize * 0, dpadPosX + dpadButtonSize * 4, dpadPosY + dpadButtonSize * 3,
		PS2::CControllerInfo::DPAD_UP, "up"));
	items.push_back(CreateButtonItem(
		dpadPosX + dpadButtonSize * 2, dpadPosY + dpadButtonSize * 3, dpadPosX + dpadButtonSize * 4, dpadPosY + dpadButtonSize * 6,
		PS2::CControllerInfo::DPAD_DOWN, "down"));
	items.push_back(CreateButtonItem(
		dpadPosX + dpadButtonSize * 0, dpadPosY + dpadButtonSize * 2, dpadPosX + dpadButtonSize * 3, dpadPosY + dpadButtonSize * 4,
		PS2::CControllerInfo::DPAD_LEFT, "left"));
	items.push_back(CreateButtonItem(
		dpadPosX + dpadButtonSize * 3, dpadPosY + dpadButtonSize * 2, dpadPosX + dpadButtonSize * 6, dpadPosY + dpadButtonSize * 4,
		PS2::CControllerInfo::DPAD_RIGHT, "right"));

	items.push_back(CreateButtonItem(
		actionPadPosX + padButtonSize * 1, actionPadPosY + padButtonSize * 0, actionPadPosX + padButtonSize * 2, actionPadPosY + padButtonSize * 1,
		PS2::CControllerInfo::TRIANGLE, "triangle"));
	items.push_back(CreateButtonItem(
		actionPadPosX + padButtonSize * 1, actionPadPosY + padButtonSize * 2, actionPadPosX + padButtonSize * 2, actionPadPosY + padButtonSize * 3,
		PS2::CControllerInfo::CROSS, "cross"));
	items.push_back(CreateButtonItem(
		actionPadPosX + padButtonSize * 0, actionPadPosY + padButtonSize * 1, actionPadPosX + padButtonSize * 1, actionPadPosY + padButtonSize * 2,
		PS2::CControllerInfo::SQUARE, "square"));
	items.push_back(CreateButtonItem(
		actionPadPosX + padButtonSize * 2, actionPadPosY + padButtonSize * 1, actionPadPosX + padButtonSize * 3, actionPadPosY + padButtonSize * 2,
		PS2::CControllerInfo::CIRCLE, "circle"));

	items.push_back(CreateAnalogStickItem(
		leftAnalogStickPosX, analogStickPosY, leftAnalogStickPosX + analogStickSize, analogStickPosY + analogStickSize,
		PS2::CControllerInfo::ANALOG_LEFT_X, PS2::CControllerInfo::ANALOG_LEFT_Y, "analogStick"));
	items.push_back(CreateAnalogStickItem(
		rightAnalogStickPosX, analogStickPosY, rightAnalogStickPosX + analogStickSize, analogStickPosY + analogStickSize,
		PS2::CControllerInfo::ANALOG_RIGHT_X, PS2::CControllerInfo::ANALOG_RIGHT_Y, "analogStick"));

	items.push_back(CreateButtonItem(
		l3ButtonPosX, lr3ButtonPosY, l3ButtonPosX + lr3ButtonSize, lr3ButtonPosY + lr3ButtonSize,
		PS2::CControllerInfo::L3, "lr", "L3"));
	items.push_back(CreateButtonItem(
		r3ButtonPosX, lr3ButtonPosY, r3ButtonPosX + lr3ButtonSize, lr3ButtonPosY + lr3ButtonSize,
		PS2::CControllerInfo::R3, "lr", "R3"));

	return items;
}