Exemplo n.º 1
0
void DetailsWidget::paintEvent(QPaintEvent *paintEvent)
{
    QWidget::paintEvent(paintEvent);

    QPainter p(this);

    QWidget *topLeftWidget = d->m_useCheckBox ? static_cast<QWidget *>(d->m_summaryCheckBox) : static_cast<QWidget *>(d->m_summaryLabelIcon);
    QPoint topLeft(topLeftWidget->geometry().left() - MARGIN, contentsRect().top());
    const QRect paintArea(topLeft, contentsRect().bottomRight());

    int topHeight = d->m_useCheckBox ? d->m_summaryCheckBox->height() : d->m_summaryLabel->height();
    if (d->m_state == DetailsWidget::Expanded || d->m_state == DetailsWidget::Collapsed) // Details Button is shown
        topHeight = qMax(d->m_detailsButton->height(), topHeight);

    if (d->m_state == Collapsed) {
        if (d->m_collapsedPixmap.isNull() ||
            d->m_collapsedPixmap.size() != size())
            d->m_collapsedPixmap = createBackground(paintArea.size(), topHeight, this);
        p.drawPixmap(paintArea, d->m_collapsedPixmap);
    } else {
        if (d->m_expandedPixmap.isNull() ||
            d->m_expandedPixmap.size() != size())
            d->m_expandedPixmap = createBackground(paintArea.size(), topHeight, this);
        p.drawPixmap(paintArea, d->m_expandedPixmap);
    }
}
Exemplo n.º 2
0
bool BattleScene::init()
{
	Layer::init();
	currentLayer = this;
	Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGB565);

	setCamera();
	controlCamera();
	setCameraMask(2);
	createBackground();
	enableTouch();
	initUILayer();
	GameMaster::create();

	MessageDispatchCenter::getInstance()->registerMessage(MessageType::BLOOD_MINUS, [](Actor * heroActor)
	{
		uiLayer->bloodDrop(heroActor);
	});
	MessageDispatchCenter::getInstance()->registerMessage(MessageType::ANGRY_CHANGE, [](Actor * heroActor)
	{
		uiLayer->angryChange(heroActor);
	});

	scheduleUpdate();
	return true;
}
GameState::GameState(StateStack& stack, Context context)
	: State(stack, context)
	, mECSM()
	, clearColor(sf::Color(237,182,31))
{

	initializeSystems();
	createBackground();
	createSwing();
	startMusic();

	// TESTING

	sf::Sprite* personSprite = new sf::Sprite();
	personSprite->setTexture(getContext().textures->get(Textures::Person));
	personSprite->setScale(sf::Vector2f(-4.0f, 4.0f));

	Entity* testPerson = new Entity(2);
	testPerson->addComponent(new ComponentPosition(20, 550));
	testPerson->addComponent(new ComponentVelocity(0.1f, 0));
	testPerson->addComponent(new ComponentSprite(personSprite));

	mECSM.registerEntity(testPerson);

	// DONE TESTING

}
Exemplo n.º 4
0
void AttitudeIndicator::itemSizeChanged(float w, float h) {
    // The guage has changed size: redraw the cached pixmaps.
    createCard(w,h);
    createFrame(w,h);
    createGlass(w,h);
    createBackground(w,h);
}
Exemplo n.º 5
0
// ---
QGAMES::Background* QGAMES::ObjectBuilder::readBackground (TiXmlElement* e)
{
	// To create a background a reference to the form builder 
	// ...has to be set up...
	assert (_formBuilder);

	// Gets the id, it has to exist!
	int id = -1;
	e -> Attribute (__QGAMES_BKATTRID__, &id);
	assert (id != -1);

	// Gets the form...and it has to be an sprite2D!
	QGAMES::Sprite2D* frm = dynamic_cast <QGAMES::Sprite2D*> 
		(_formBuilder -> form (std::stoi (e -> Attribute (__QGAMES_BKATTRFORM__))));
	assert (frm);

	// Gets the number of times the background is repeted
	// This parameter is not mandatory!
	int nT = 1; // By default!
	e -> Attribute (__QGAMES_BKATTRTIMES__, &nT);

	// Read the attributes...if any
	std::map <std::string, std::string> pties;
	for (TiXmlElement* groupElement = e -> FirstChildElement ();
		groupElement != NULL; groupElement = groupElement -> NextSiblingElement ())
		if (strcmp (groupElement -> Value (), __QGAMES_ATTRSBLOCK__) == 0)
			pties = readPropertiesSection (groupElement);

	// Create the image object and return...
	return (createBackground (id, QGAMES::Position::_cero, frm, nT, pties));
}
Exemplo n.º 6
0
struct vectorObjects initVectorObjects() {
	struct vectorObjects result;
	result.bg = createBackground();
	result.hour = creatRow(HOUR_SIZE);
	result.min = creatRow(MIN_SIZE);
	result.sec = creatRow(SEC_SIZE);
	return result;
}
Exemplo n.º 7
0
void Slider::draw()
{
    if (! background)
        createBackground();
    screen.draw(left, top, background);
    screen.addRegionToUpdate(left, top, width, height);
    int posX = valueToX(value);
    SDL_Surface *s = highlight ? activeSlider : slider;
    screen.draw(left + posX, top, s);
}
Exemplo n.º 8
0
TDeskTop::TDeskTop( const TRect& bounds ) :
    TGroup(bounds),
    TDeskInit( &TDeskTop::initBackground )
{
    growMode = gfGrowHiX | gfGrowHiY;

    if( createBackground != 0 &&
        (background = createBackground( getExtent() )) != 0 )
        insert( background );
}
Exemplo n.º 9
0
bool BackgroundLayer::init()
{
	Layer::init();
	visibleSize = Director::getInstance()->getVisibleSize();
	origin = Director::getInstance()->getVisibleOrigin();

	createBackground("sprites/bg.png");

	scheduleUpdate();
	return true;
}
Exemplo n.º 10
0
int Engine::getReady() {
    if ((init()) or
        (createWindow(win_width, win_height)) or
        (createRenderer()) or
        (createBackground()) or
        (initializeImageSystem()) or
        (initializeAudioSystem()) or
        (initializeFontTTF())) {
        cout << "Something went wrong! I'm afraid we're going to crash, soldier!" << endl;
        return 1;
    }
    return 0;
}
Exemplo n.º 11
0
void TimeScene::setupScene() {
    this->clear();

    calcZoom();
    int projects = _model->rowCount(QModelIndex());
    for (int x = 0; x < projects; x++) {
        QModelIndex index = _model->index(x, 0);
        drawIndex(index);
    }
    this->_viewSizeHeight = _currentY; // + headerSizeHint().height()
    createBackground();
    setSceneRect(0, 0, _viewSizeWidth, _viewSizeHeight);
}
Exemplo n.º 12
0
void Button::paintEvent(QPaintEvent *event)
{
	Q_UNUSED(event);

	QPainter painter(this);

	if (text() != "##Left##" && text() != "##Right##")
	{
		painter.setPen(QColor(isEnabled() ? (isDown() ? Qt::lightGray : Qt::white) : Qt::darkGray));
		painter.drawText(rect(), Qt::AlignCenter | Qt::TextShowMnemonic, text());
	}
	painter.drawImage(0, 0, createBackground());
}
Exemplo n.º 13
0
void KisLightSource::deselect()
{
    m_moving = true;
    m_isselected = false;
    setPixmap(createBackground());
    QSize newsize(m_icondiameter, m_icondiameter);
    QPoint newtopleft(pos().x() + (m_selecthalothickness),
                     pos().y() + (m_selecthalothickness));

    setGeometry(QRect(newtopleft, newsize));
        m_center = QPointF(qreal(size().width()) / 2, qreal(size().height()) / 2);
    deselected();
}
Exemplo n.º 14
0
Map::Map(int largeur, int hauteur, string fichier, Level* lvl)
: Reader(), _foreground(), _backgroundLv1(), _backgroundLv2()
{
    string chemin = "Tileset/"+fichier;
    _filePathTileset = "Tileset/"+fichier;
    _tileset.loadFromFile(chemin.c_str());
    _largeurMap = largeur;
    _hauteurMap = hauteur;
    _mapSize = sf::Vector2i(_largeurMap*32,_hauteurMap*32);
    _filePath = fichier;
    _mapArray = new int [_largeurMap*_hauteurMap];
    for (int i(0);i<_largeurMap*_hauteurMap;i++)
    {
        _mapArray[i] = 121;
        _tabMap.push_back(1024);
        _tabForeground.push_back(1024);
        _tabBackgroundLv1.push_back(1024);
        _tabBackgroundLv2.push_back(1024);
    }
    lvl->setForeground(createMap());
    lvl->setbackgroundLv1(createBackground("Lv1"));
    lvl->setbackgroundLv2(createBackground("Lv2"));
    //load();
}
Exemplo n.º 15
0
int main(int, char **)
{
    // create the model
    osg::Group* root = new osg::Group;
    root->addChild( createScene() );
    root->addChild( createBackground() );

    //osgDB::writeNodeFile(*root,"geoemtry.osgt");

    osgViewer::Viewer viewer;

    // add model to viewer.
    viewer.setSceneData( root );

    return viewer.run();
}
Exemplo n.º 16
0
bool GameScene::init()
{
    if (!CCLayer::init()) {
        return false;
    }
    
    //背景を追加する
    createBackground();
    
    //ネコを表示する
    createCat();
    
    //スコアと残り時間を表示する
    createLabel();
    
    return true;
}
Exemplo n.º 17
0
//KisLightSource::KisLightSource(QColor color = QColor(0, 0, 0), qreal azimuth = 0, qreal altitude = 90, QWidget *parent = 0)
KisLightSource::KisLightSource(QColor color, qreal azimuth, qreal altitude, QWidget *parent)
            : QLabel(parent)
{
    m_moving = false;

    // Set basic properties
    m_color = color;
    m_azimuth = azimuth;
    m_altitude = altitude;

    // Deduce other properties from the basic set
    qreal m;  //2D vector magnitude
    lightVector.setZ( sin( altitude * M_PI / 180 ) );
    m = cos( altitude * M_PI / 180);

    qDebug() << "m: " << m;
    qDebug() << "orig Altitude: " << altitude;

    // take the negative azimuth to make the spinning counterclockwise
    // TODO BUG make it negative again
    lightVector.setX( cos( azimuth * M_PI / 180 ) * m );
    lightVector.setY( sin( azimuth * M_PI / 180 ) * m );

    // Create background
    m_icondiameter = 13;
    m_selecthalothickness = 3;
    setPixmap(createBackground());
    resize(m_icondiameter, m_icondiameter);

    m_center = QPointF(qreal(size().width()) / 2, qreal(size().height()) / 2);

    RGBvalue << color.redF();
    RGBvalue << color.greenF();
    RGBvalue << color.blueF();

    show();
    if (parentWidget())
        this->parentWidget()->update();

    qDebug() << lightVector;
}
Exemplo n.º 18
0
/*!
  Initialisation of Ogre with a color background.

  Load the plugins that are specified in the plugins.cfg or
  plugins_d.cfg files. These files are located in
  VISP_HAVE_OGRE_PLUGINS_PATH folder that is defined in vpConfig.h.
  Note that plugins.cfg file is always considered under Unix
  platforms. The file plugins_d.cfg is only considered under Windows
  when the build type is Debug.

  Load also the resources that are defined in the resources.cfg
  file. This file is located in VISP_HAVE_OGRE_RESOURCES_PATH folder
  that is defined in vpConfig.h.

  Create also a color background used to display the image.

  \param I : Image that is displayed in the background.

  \param bufferedKeys : If true, use of buffered input for the keyboard (see
  Ogre documentation). Note that this parameter is only useful if OIS is used.

  \param hidden : If true, the created window will be hidden.
  Note that this functionnality requires Ogre3D 1.8.1 at least.

  \exception vpException::ioError : If the required plugins.cfg /
  plugins_d.cfg or resources.cfg files are not accessible.

*/
void vpAROgre::init(vpImage<vpRGBa> &I,
		    bool
#ifdef VISP_HAVE_OIS
		    bufferedKeys
#endif
        ,bool hidden
		    )
{
  mBackgroundWidth = I.getWidth();
  mBackgroundHeight = I.getHeight();

  init(
#ifdef VISP_HAVE_OIS
       bufferedKeys,
#else
       false,
#endif
       hidden
       );
  // Create the background image which will come from the grabber
  createBackground(I);
}
Exemplo n.º 19
0
bool MainScene::init() {
	if (!Layer::init())
		return false;

	size = Director::getInstance()->getVisibleSize();

	createBackground();
	createCloud();
	createMouse();
	createProp();
	createCucrbit();
	createWeather();
	eventProcess();
	initCucurbit();
	createProgress();
	createProgressBlood();

	LoadingScene::loadData();

	if (hudLayer != nullptr)
		hudLayer->updateIQ();

	scheduleProcess();

	isHold = false;
	isFall = false;
	isAction = false;
	isJump = false;
	isSkateboardHit = false;
	isSkateboardFinishAction = false;
	isSkateboard = false;
	isSholvePropChose = false;
	mouseFallingSnare = nullptr;
	skateboard = nullptr;
	snares.clear();

	return true;
}
Exemplo n.º 20
0
CSMeter::CSMeter(wxWindow* parent, int id, const wxPoint& pos, const wxSize& size, long style, const wxString& name) :
wxPanel(parent, id, pos, size, style, name),
m_width(size.GetWidth()),
m_height(size.GetHeight()),
m_rxBackground(NULL),
m_txBackground(NULL),
m_bitmap(NULL),
m_menu(NULL),
m_rxMenu(NULL),
m_txMenu(NULL),
m_rxMeter(METER_SIGNAL),
m_txMeter(METER_POWER),
m_lastLevel(999.9F),
m_txOn(false)
{
	m_bitmap       = new wxBitmap(m_width, m_height);
	m_rxBackground = new wxBitmap(m_width, m_height);
	m_txBackground = new wxBitmap(m_width, m_height);

	m_rxMenu = new wxMenu();
	m_rxMenu->AppendRadioItem(MENU_I_INPUT,    _("I Input"));
	m_rxMenu->AppendRadioItem(MENU_Q_INPUT,    _("Q Input"));
	m_rxMenu->AppendRadioItem(MENU_SIGNAL,     _("Strength"));
	m_rxMenu->AppendRadioItem(MENU_AVG_SIGNAL, _("Avg Strength"));

	m_txMenu = new wxMenu();
	m_txMenu->AppendRadioItem(MENU_MICROPHONE, _("Microphone"));
	m_txMenu->AppendRadioItem(MENU_COMPRESSED, _("Compressed"));
	m_txMenu->AppendRadioItem(MENU_ALC,        _("Post ALC"));
	m_txMenu->AppendRadioItem(MENU_POWER,      _("Power"));

	m_menu = new wxMenu();
	m_menu->Append(MENU_RX_MENU, _("Receive"),  m_rxMenu);
	m_menu->Append(MENU_TX_MENU, _("Transmit"), m_txMenu);

	createBackground();
	setLevel(0.0);
}
Exemplo n.º 21
0
BOOL xcfg_OnCreate(   HWND hwnd, LPCREATESTRUCT lpcs){
  createBackground(hwnd);

  GLBL_FONT = ::CreateFont(
  16, // logical height of font
  0, // logical average char width, 0 = best match
  0, // angle of escapement
  0, // base-line orientation angle
  FW_BOLD, // font weight
  FALSE, // italic attribute flag
  FALSE, // underline attribute flag
  FALSE, // strikeout attribute flag
  DEFAULT_CHARSET, // character set identifier
  OUT_TT_PRECIS, // output preacision; prefer TrueType fonts
  CLIP_DEFAULT_PRECIS, // clipping precision
  ANTIALIASED_QUALITY, // output quality
  FF_SWISS|VARIABLE_PITCH, // pitch and family
  NULL); //any 
  //=============================================================
  // Now, create our controls
  SliceM = new cSliceM(hwnd);
  return TRUE;
}
Exemplo n.º 22
0
int main(int argc, char** argv)
{
	// create the model
	osg::Group* root = new osg::Group;
	root->addChild(createScene());
	root->addChild(createBackground());

	root->getOrCreateStateSet();

	osg::ArgumentParser arguments(&argc, argv);
	osgViewer::Viewer viewer(arguments);

	osgUtil::ShaderGenVisitor shaderGenVisitor;
	shaderGenVisitor.setRootStateSet(viewer.getCamera()->getStateSet());
	root->accept(shaderGenVisitor);

	//osgDB::writeNodeFile(*root,"geoemtry.osgt");

	// add model to viewer.
	viewer.setSceneData(root);

	return viewer.run();
}
Exemplo n.º 23
0
WorldView::WorldView(std::shared_ptr<WorldState> state, TileMap tileMap, float width, float height)
    : View{width, height}, state{state}, cameraFollow{nullptr}, tileMap{tileMap} {
    this->fixedView = this->state->engine->window.getView();
    this->dynamicView = this->state->engine->window.getView();
    createBackground();
}
Exemplo n.º 24
0
void InitLivin(int width, int height){
   int i;
   char letterpath[] = "data/x.obj"; /* character mesh mask */
   char letterlist[LETTERNUM] = "bceginrsty"; /* Cybernetic genetics characters */
   char greetingspath[21];

   /* OpenGL related initialization */
   glClearColor(0.0, 0.0, 0.0, 0.0);
   glEnable(GL_DEPTH_TEST);
   glEnable(GL_BLEND);
   glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
   
   perspectiveMatrix(pmatrix, 35.0, (float)width/(float)height, 0.1, 1500.0);

   /* Demo related initialization */
   head      = openDepthVideo("data/head.dv");
   matat     = openDepthVideo("data/matat.dv");
   face      = initFace("shaders/face.vs", "shaders/face.fs");
   armface   = initFace("shaders/face.vs", "shaders/face.fs");
   knock     = openOutline("data/knock.pyd",           "shaders/knock.vs",   "shaders/knock.fs");
   jump      = openOutline("data/jump.pyd",            "shaders/jump.vs",    "shaders/outline.fs");
   hang      = openOutline("data/hanging.pyd",         "shaders/hang.vs",    "shaders/outline.fs");
   run       = openOutline("data/run.pyd",             "shaders/run.vs",     "shaders/outline.fs");
   falling   = openOutline("data/falling_letters.pyd", "shaders/run.vs",     "shaders/outline.fs");
   door      = openOutline("data/door.pyd",            "shaders/door.vs",    "shaders/door.fs");
   trap      = openOutline("data/trap.pyd",            "shaders/trap.vs",    "shaders/outline.fs");
   fractalme = openOutline("data/fractalme.pyd",       "shaders/frme.vs",    "shaders/frme.fs");
   /* Acrobatic outlines */
   tiger     = openOutline("data/tiger.pyd",           "shaders/acrobat.vs", "shaders/outline.fs");
   hop       = openOutline("data/hop.pyd",             "shaders/acrobat.vs", "shaders/outline.fs");
   katf      = openOutline("data/kezenatfordulas.pyd", "shaders/acrobat.vs", "shaders/outline.fs");
   flip      = openOutline("data/flip.pyd",            "shaders/acrobat.vs", "shaders/outline.fs");
   run2      = openOutline("data/run2.pyd",            "shaders/acrobat.vs", "shaders/outline.fs");
   catwheel  = openOutline("data/catwheel.pyd",        "shaders/acrobat.vs", "shaders/outline.fs");
   tbill     = openOutline("data/tarkobillenes.pyd",   "shaders/acrobat.vs", "shaders/outline.fs");

   createBox();
   createBackground();
   initGreetings();
   createDistBack();
   bigcube = createBigCube(600);

   titletex   = loadPNGTexture("data/title.png");
   greentex   = loadPNGTexture("data/green.png");
   creditstex = loadPNGTexture("data/credits.png");
   bgalphatex = loadPNGTexture("data/bg_alpha.png");
   whitetex   = loadPNGTexture("data/white.png");
   icubetex   = loadPNGTexture("data/innercube.png");
   headouttex = loadPNGTexture("data/headout.png");
   chesstex   = loadPNGTexture("data/chessboard.png");
   atpartytex = loadPNGTexture("data/at_party.png");

   for(i = 0; i < 12; i++){
      sprintf(greetingspath, "data/greetings%d.png", i+1);
      greetingstex[i] = loadPNGTexture(greetingspath);
   }

   for(i = 0; i < MAXKNOCKINGMAN; i++){
      knockingmans[i * 3 + 0] = drand48() * 4.0 + 8.0;
      knockingmans[i * 3 + 1] = drand48() * 6.0 + 1.0;
      knockingmans[i * 3 + 2] = drand48();
   }

   /* Shaders */
   background_src[0] = loadShader(GL_VERTEX_SHADER,          "shaders/background.vs");
   background_src[1] = loadShader(GL_FRAGMENT_SHADER,        "shaders/background.fs");
   background_src[2] = loadShader(GL_TESS_EVALUATION_SHADER, "shaders/background.te");
   background_src[3] = loadShader(GL_TESS_CONTROL_SHADER,    "shaders/background.tc");
   background_src[4] = loadShader(GL_GEOMETRY_SHADER,        "shaders/background.gs");
   background_shader = createProgram(5, background_src);

   title_src[0]      = background_src[0];
   title_src[1]      = loadShader(GL_FRAGMENT_SHADER, "shaders/title.fs");
   title_src[2]      = background_src[2];
   title_src[3]      = background_src[3];
   title_src[4]      = background_src[4];
   title_shader      = createProgram(5, title_src);

   scroll_src[0]     = background_src[0];
   scroll_src[1]     = loadShader(GL_FRAGMENT_SHADER, "shaders/scroll.fs");
   scroll_src[2]     = background_src[2];
   scroll_src[3]     = background_src[3];
   scroll_src[4]     = background_src[4];
   scroll_shader     = createProgram(5, scroll_src);

   credits_src[0]    = background_src[0];
   credits_src[1]    = loadShader(GL_FRAGMENT_SHADER, "shaders/credits.fs");
   credits_src[2]    = background_src[2];
   credits_src[3]    = background_src[3];
   credits_src[4]    = loadShader(GL_GEOMETRY_SHADER, "shaders/credits.gs");
   credits_shader    = createProgram(5, credits_src);

   letter_src[0]     = loadShader(GL_VERTEX_SHADER,   "shaders/letter.vs");
   letter_src[1]     = loadShader(GL_FRAGMENT_SHADER, "shaders/letter.fs");
   letter_shader     = createProgram(2, letter_src);

   cube_src[0]       = loadShader(GL_VERTEX_SHADER,   "shaders/cube.vs");
   cube_src[1]       = loadShader(GL_FRAGMENT_SHADER, "shaders/cube.fs");
   cube_src[2]       = loadShader(GL_GEOMETRY_SHADER, "shaders/cube.gs");
   cube_shader       = createProgram(3, cube_src);

   gr_src[0]         = loadShader(GL_VERTEX_SHADER,   "shaders/greetings.vs");
   gr_src[1]         = loadShader(GL_FRAGMENT_SHADER, "shaders/greetings.fs");
   gr_shader         = createProgram(2, gr_src);

   dbgr_src[0]       = loadShader(GL_VERTEX_SHADER,   "shaders/dbgr.vs");
   dbgr_src[1]       = loadShader(GL_FRAGMENT_SHADER, "shaders/dbgr.fs");
   dbgr_shader       = createProgram(2, dbgr_src);

   bigcube_src[0]    = loadShader(GL_VERTEX_SHADER,   "shaders/bigcube.vs");
   bigcube_src[1]    = loadShader(GL_FRAGMENT_SHADER, "shaders/bigcube.fs");
   bigcube_shader    = createProgram(2, bigcube_src);

   /* Letters */
   for(i = 0; i < LETTERNUM; i++){
      letterpath[5] = letterlist[i];
      letters[i] = loadOBJ(letterpath);

      glBindVertexArray(letters[i]->vao);
      bindVarToBuff(letter_shader, "vertex", letters[i]->vbo[MESHVERTEXINDEX], 3);
      bindVarToBuff(letter_shader, "normal", letters[i]->vbo[MESHNORMALINDEX], 3);
      bindVarToBuff(letter_shader, "tcoord", letters[i]->vbo[MESHTEXINDEX],    2);
   }

   cube = loadOBJ("data/cube.obj");
   glBindVertexArray(cube->vao);
   bindVarToBuff(cube_shader, "vertex", cube->vbo[MESHVERTEXINDEX], 3);
   bindVarToBuff(cube_shader, "normal", cube->vbo[MESHNORMALINDEX], 3);
   bindVarToBuff(cube_shader, "tcoord", cube->vbo[MESHTEXINDEX],    2);

   initExplosion();

   startTime();
}
Exemplo n.º 25
0
bool GameMain::init()
{
    if(!Layer::init()){return false;}
    
    createBackground();
    createLabel();
    createCards();
    createBoards();
    createMenuButton();
    settingStart();
    
    auto listener=EventListenerTouchOneByOne::create();
    //ドラッグ開始
    listener->onTouchBegan=[this](Touch* touch,Event* event){
        ////
        if(!_moveCards.empty()){
            if(_moveCards.front()->getNumberOfRunningActions()){//ダブルタッチアニメーション中
                auto card=_moveCards.front();
                card->stopAllActions();//アニメーションをキャンセル
                this->dragTouchEnded(_homeCellLayer->getHomeCellTalonPosition(card->getCardType()));//CallFuncの処理を実行
            }
        }
        ////
        
        auto position=touch->getLocation();
        if(_gameState==GameState::TOUCH_WAITING){
            _moveCards.clear();
            if(TALON_AREA_RECT.containsPoint(position)){
                _moveCards=_talonLayer->dragCards(position);
                this->setDragLayer(_talonLayer);
            }else if(BOARD_CARD_AREA_RECT.containsPoint(position)){
                _moveCards=_boardCardLayer->dragCards(position);
                this->setDragLayer(_boardCardLayer);
            }else if(HOME_CELL_AREA_RECT.containsPoint(position)){
                _moveCards=_homeCellLayer->dragCards(position);
                this->setDragLayer(_homeCellLayer);
            }
            
            if(!_moveCards.empty()){//カードがドラッグできれば
                auto cardPosition=Vec2(0,-CARD_SIZE.height/4);
                int z=1;
                for(auto card:_moveCards){
                    card->setPosition(cardPosition);
                    _moveLayer->addChild(card,z);
                    cardPosition+=TALON_DIFF;
                    z++;
                }
                
                _moveLayer->setPosition(position);
                
                _gameState=GameState::DRAG;
                
                //ダブルタップ処理
                _doubleTouchFlag=false;
                if(_dragLayer==_talonLayer || _dragLayer==_boardCardLayer){//山札あるいは場札からのドロップ
                    if(_homeCellLayer->checkDropCard(_moveCards)){//ホームセルに置けるカードである
                        _doubleTouchFlag=true;//ダブルタップ処理フラグをtrue
                        _oneTouch=false;//一回タップされたかのフラグをfalse
                        _touchTime=0;//タップ時間の初期化
                    }
                }
            }else{
                this->setDragLayer(nullptr);
            }
        }
        return true;
    };
    //ドロップ、山札の切り替え
    listener->onTouchEnded=[this](Touch* touch,Event* event){
        auto position=touch->getLocation();
        if(_gameState==GameState::TOUCH_WAITING){
            if(TALON_AREA_RECT.containsPoint(position)){
                if(_talonLayer->touchTalonCard(position)){
                    //山札が一巡
                    if(_talonLayer->getPullCount()==3){
                        //引くカードが3枚ずつの場合-20
                        this->updateScore(-20);
                    }else if(_talonLayer->getPullCount()==1){
                        //引くカードが1枚ずつの場合-100
                        this->updateScore(-100);
                    }else{
                        log("Talon::_pullCoount neither 1 nor 3.");
                    }
                }
            }
        }else if(_gameState==GameState::DRAG){
            if(_doubleTouchFlag){//ダブルタップを行う可能性がある
                if(_oneTouch){//既に一度タップされている
                    if(_touchTime<TOUCH_TIME_PERIOD){//ダブルタップ受付時間以内
                        this->unschedule(DRAG_SCHEDULE);
                        auto card=_moveCards.front();
                        //this->dragTouchEnded(_homeCellLayer->getHomeCellTalonPosition(card->getCardType()));
                        _doubleTouchFlag=false;
                        
                        ////
                        //カードを移すホームセルの位置
                        auto homeCellPosition=_homeCellLayer->getHomeCellTalonPosition(card->getCardType());
                        //_moveLayerとGameMainレイヤーは基準座標が違うためconvertする
                        card->runAction(Sequence::create(MoveTo::create(0.3,_moveLayer->convertToNodeSpace(homeCellPosition))
                                                         ,CallFunc::create([this,homeCellPosition](){
                            this->dragTouchEnded(homeCellPosition);
                        })
                                                         ,NULL));
                        ////
                    }
                }else{
                    if(_touchTime<TOUCH_TIME_PERIOD){//ダブルタップ受付時間以内
                        _oneTouch=true;
                        //ダブルタップされなかったときのためにスケジュールを設定
                        this->scheduleOnce([this,position](float dt){
                            this->dragTouchEnded(position);
                            _doubleTouchFlag=false;
                        },TOUCH_TIME_PERIOD-_touchTime+0.1,DRAG_SCHEDULE);
                    }else{
                        this->dragTouchEnded(position);
                        _doubleTouchFlag=false;
                    }
                }
            }else{
                this->dragTouchEnded(position);
            }
        }
    };
    //ドロップ中の移動
    listener->onTouchMoved=[this](Touch* touch,Event* event){
        auto position=touch->getLocation();
        if(_gameState==GameState::DRAG){
            _moveLayer->setPosition(position);
        }
    };
    //キャンセル
    listener->onTouchCancelled=[this](Touch* touch,Event* event){
        if(_gameState==GameState::DRAG){
            _moveLayer->removeAllChildren();
            _dragLayer->cancelCards(_moveCards);
            _gameState=GameState::TOUCH_WAITING;
        }
    };
    //test
    
    Director::getInstance()->getEventDispatcher()->addEventListenerWithSceneGraphPriority(listener,this);
    
    return true;
}
Exemplo n.º 26
0
void FieldRoom::createRoom()
{
	createBackground();
	createForeground();
}
int ONScripter::loadSaveFile2( int file_version )
{
    deleteNestInfo();
    
    int i, j;
    
    readInt(); // 1
    if ( readInt() == 1 ) sentence_font.is_bold = true;
    else                  sentence_font.is_bold = false;
    if ( readInt() == 1 ) sentence_font.is_shadow = true;
    else                  sentence_font.is_shadow = false;

    readInt(); // 0
    rmode_flag = (readInt()==1)?true:false;
    sentence_font.color[0] = readInt();
    sentence_font.color[1] = readInt();
    sentence_font.color[2] = readInt();
    cursor_info[0].remove();

    char *tmp_name = NULL;
    readStr( &tmp_name );
    loadCursor(0, tmp_name, 0, 0);
    readStr( &tmp_name );
    loadCursor(1, tmp_name, 0, 0);
    if (tmp_name) delete[] tmp_name;

    window_effect.effect = readInt();
    window_effect.duration = readInt();
    readStr( &window_effect.anim.image_name ); // probably

    sentence_font.clear();
    sentence_font.ttf_font  = NULL;
    sentence_font.top_xy[0] = readInt();
    sentence_font.top_xy[1] = readInt();
    sentence_font.num_xy[0] = readInt();
    sentence_font.num_xy[1] = readInt();
    sentence_font.font_size_xy[0] = readInt();
    sentence_font.font_size_xy[1] = readInt();
    sentence_font.pitch_xy[0] = readInt();
    sentence_font.pitch_xy[1] = readInt();
    for ( i=0 ; i<3 ; i++ )
        sentence_font.window_color[2-i] = readChar();
    if ( readChar() == 0x00 ) sentence_font.is_transparent = true;
    else                      sentence_font.is_transparent = false;
    sentence_font.wait_time = readInt();

    AnimationInfo *ai = &sentence_font_info;
    ai->orig_pos.x = readInt();
    ai->orig_pos.y = readInt();
    ai->orig_pos.w = readInt() + 1 - ai->orig_pos.x;
    ai->orig_pos.h = readInt() + 1 - ai->orig_pos.y;
    ai->scalePosXY( screen_ratio1, screen_ratio2 );
    ai->scalePosWH( screen_ratio1, screen_ratio2 );
    readStr( &ai->image_name );
    if ( !sentence_font.is_transparent && ai->image_name ){
        parseTaggedString( ai );
        setupAnimationInfo( ai );
    }

    if ( readInt() == 1 ) cursor_info[0].abs_flag = false;
    else                  cursor_info[0].abs_flag = true;
    if ( readInt() == 1 ) cursor_info[1].abs_flag = false;
    else                  cursor_info[1].abs_flag = true;
    cursor_info[0].orig_pos.x = readInt();
    cursor_info[1].orig_pos.x = readInt();
    cursor_info[0].orig_pos.y = readInt();
    cursor_info[1].orig_pos.y = readInt();
    cursor_info[0].scalePosXY( screen_ratio1, screen_ratio2 );
    cursor_info[1].scalePosXY( screen_ratio1, screen_ratio2 );

    // load background surface
    bg_info.remove();
    readStr( &bg_info.file_name );
    createBackground();

    for ( i=0 ; i<3 ; i++ ){
        tachi_info[i].remove();
        readStr( &tachi_info[i].image_name );
        if ( tachi_info[i].image_name ){
            parseTaggedString( &tachi_info[i] );
            setupAnimationInfo( &tachi_info[i] );
        }
    }

    for ( i=0 ; i<3 ; i++ ) 
        tachi_info[i].orig_pos.x = readInt();
    for ( i=0 ; i<3 ; i++ ) 
        tachi_info[i].orig_pos.y = readInt();
    for ( i=0 ; i<3 ; i++ ) 
        tachi_info[i].scalePosXY( screen_ratio1, screen_ratio2 );

    readInt(); // 0
    readInt(); // 0
    readInt(); // 0
    
    if (file_version >= 203){
        readInt(); // -1
        readInt(); // -1
        readInt(); // -1
    }
    
    for ( i=0 ; i<MAX_SPRITE_NUM ; i++ ){
        AnimationInfo *ai = &sprite_info[i];
        
        ai->remove();
        readStr( &ai->image_name );
        if ( ai->image_name ){
            parseTaggedString( ai );
            setupAnimationInfo( ai );
        }
        ai->orig_pos.x = readInt();
        ai->orig_pos.y = readInt();
        ai->scalePosXY( screen_ratio1, screen_ratio2 );
        if ( readInt() == 1 ) ai->visible = true;
        else                  ai->visible = false;
        ai->current_cell = readInt();
        if (file_version >= 203){
            j = readInt();
            if (j == -1)
                ai->trans = 256;
            else
                ai->trans = j;
        }
    }

    readVariables( 0, script_h.global_variable_border );

    // nested info
    int num_nest =readInt();
    last_nest_info = &root_nest_info;
    if (num_nest > 0){
        file_io_buf_ptr += (num_nest-1)*4;
        while( num_nest > 0 ){
            NestInfo *info = new NestInfo();
            if (last_nest_info == &root_nest_info) last_nest_info = info;
        
            i = readInt();
            if (i > 0){
                info->nest_mode = NestInfo::LABEL;
                info->next_script = script_h.getAddress( i );
                file_io_buf_ptr -= 8;
                num_nest--;
            }
            else{
                info->nest_mode = NestInfo::FOR;
                info->next_script = script_h.getAddress( -i );
                file_io_buf_ptr -= 16;
                info->var_no = readInt();
                info->to = readInt();
                info->step = readInt();
                file_io_buf_ptr -= 16;
                num_nest -= 4;
            }
            info->next = root_nest_info.next;
            if (root_nest_info.next) root_nest_info.next->previous = info;
            root_nest_info.next = info;
            info->previous = &root_nest_info;
        }
        num_nest = readInt();
        file_io_buf_ptr += num_nest*4;
    }

    if (readInt() == 1) monocro_flag = true;
    else                monocro_flag = false;
    for ( i=0 ; i<3 ; i++ )
        monocro_color[2-i] = readInt();
    for ( i=0 ; i<256 ; i++ ){
        monocro_color_lut[i][0] = (monocro_color[0] * i) >> 8;
        monocro_color_lut[i][1] = (monocro_color[1] * i) >> 8;
        monocro_color_lut[i][2] = (monocro_color[2] * i) >> 8;
    }
    nega_mode = readInt();
    
    // ----------------------------------------
    // Sound
    stopCommand();
    loopbgmstopCommand();
    stopAllDWAVE();

    readStr( &midi_file_name ); // MIDI file
    readStr( &wave_file_name ); // wave, waveloop
    i = readInt();
    if ( i >= 0 ) current_cd_track = i;

    // play, playonce MIDI
    if ( readInt() == 1 ){
        midi_play_loop_flag = true;
        current_cd_track = -2;
        playSound(midi_file_name, SOUND_MIDI, midi_play_loop_flag);
    }
    else
        midi_play_loop_flag = false;
    
    // wave, waveloop
    if ( readInt() == 1 ) wave_play_loop_flag = true;
    else                  wave_play_loop_flag = false;
    if ( wave_file_name && wave_play_loop_flag )
        playSound(wave_file_name, SOUND_CHUNK, wave_play_loop_flag, MIX_WAVE_CHANNEL);

    // play, playonce
    if ( readInt() == 1 ) cd_play_loop_flag = true;
    else                  cd_play_loop_flag = false;
    if ( current_cd_track >= 0 ) playCDAudio();

    // bgm, mp3, mp3loop
    if ( readInt() == 1 ) music_play_loop_flag = true;
    else                  music_play_loop_flag = false;
    if ( readInt() == 1 ) mp3save_flag = true;
    else                  mp3save_flag = false;
    readStr( &music_file_name );
    if ( music_file_name ){
        playSound(music_file_name, SOUND_MUSIC | SOUND_MIDI,
                  music_play_loop_flag, MIX_BGM_CHANNEL);
    }

    erase_text_window_mode = readInt();
    readInt(); // 1

    barclearCommand();
    for ( i=0 ; i<MAX_PARAM_NUM ; i++ ){
        j = readInt();
        if ( j != 0 ){
            ai = bar_info[i] = new AnimationInfo();
            ai->trans_mode = AnimationInfo::TRANS_COPY;
            ai->num_of_cells = 1;

            ai->param = j;
            ai->orig_pos.x = readInt();
            ai->orig_pos.y = readInt();
            ai->max_width  = readInt();
            ai->orig_pos.w = 0;
            ai->orig_pos.h = readInt();
            ai->max_param  = readInt();

            ai->scalePosXY( screen_ratio1, screen_ratio2 );

            for ( j=0 ; j<3 ; j++ )
                ai->color[2-j] = readChar();
            readChar(); // 0x00

            int w = ai->max_width * ai->param / ai->max_param;
            if ( ai->max_width > 0 && w > 0 ) ai->orig_pos.w = w;

            ai->scalePosWH( screen_ratio1, screen_ratio2 );
            ai->allocImage( ai->pos.w, ai->pos.h );
            ai->fill( ai->color[0], ai->color[1], ai->color[2], 0xff );
        }
        else{
            readInt(); // -1
            readInt(); // 0
            readInt(); // 0
            readInt(); // 0
            readInt(); // 0
            readInt(); // 0
        }
    }

    prnumclearCommand();
    for ( i=0 ; i<MAX_PARAM_NUM ; i++ ){
        j = readInt();
        if ( prnum_info[i] ){
            ai = prnum_info[i] = new AnimationInfo();
            ai->trans_mode = AnimationInfo::TRANS_STRING;
            ai->num_of_cells = 1;
            ai->color_list = new uchar3[1];

            ai->param = j;
            ai->orig_pos.x = readInt();
            ai->orig_pos.y = readInt();
            ai->scalePosXY( screen_ratio1, screen_ratio2 );
            ai->font_size_xy[0] = readInt();
            ai->font_size_xy[1] = readInt();
            for ( j=0 ; j<3 ; j++ )
                ai->color_list[0][2-j] = readChar();
            readChar(); // 0x00

            char num_buf[7];
            script_h.getStringFromInteger( num_buf, ai->param, 3 );
            setStr( &ai->file_name, num_buf );

            setupAnimationInfo( ai );
        }
        else{
            readInt(); // -1
            readInt(); // 0
            readInt(); // 0
            readInt(); // 0
            readInt(); // 0
        }
    }

    readInt(); // 1
    readInt(); // 0
    readInt(); // 1
    btndef_info.remove();
    readStr( &btndef_info.image_name );
    if ( btndef_info.image_name && btndef_info.image_name[0] != '\0' ){
        parseTaggedString( &btndef_info );
        setupAnimationInfo( &btndef_info );
        SDL_SetAlpha( btndef_info.image_surface, DEFAULT_BLIT_FLAG, SDL_ALPHA_OPAQUE );
    }

    if ( file_version >= 202 )
        readArrayVariable();
    
    readInt(); // 0
    if ( readChar() == 1 ) erase_text_window_mode = 2;
    readChar(); // 0
    readChar(); // 0
    readChar(); // 0
    readStr( &loop_bgm_name[0] );
    readStr( &loop_bgm_name[1] );
    if ( loop_bgm_name[0] ) {
        if ( loop_bgm_name[1] )
            playSound(loop_bgm_name[1],
                      SOUND_PRELOAD|SOUND_CHUNK, false, MIX_LOOPBGM_CHANNEL1);
        playSound(loop_bgm_name[0],
                  SOUND_CHUNK, false, MIX_LOOPBGM_CHANNEL0);
    }

    if ( file_version >= 201 ){
        if ( readInt() == 1 ) rubyon_flag = true;
        else                  rubyon_flag = false;
        sentence_font.rubyon_flag = rubyon_flag;
        ruby_struct.font_size_xy[0] = readInt();
        ruby_struct.font_size_xy[1] = readInt();
        readStr( &ruby_struct.font_name );
    }

    if (file_version >= 204){
        readInt();
        
        for ( i=0 ; i<MAX_SPRITE2_NUM ; i++ ){
            ai = &sprite2_info[i];

            ai->remove();
            readStr( &ai->image_name );
            if ( ai->image_name ){
                parseTaggedString( ai );
                setupAnimationInfo( ai );
            }
            ai->orig_pos.x = readInt();
            ai->orig_pos.y = readInt();
            ai->scalePosXY( screen_ratio1, screen_ratio2 );
            ai->scale_x = readInt();
            ai->scale_y = readInt();
            ai->rot     = readInt();
            if ( readInt() == 1 ) ai->visible = true;
            else                  ai->visible = false;
            j = readInt();
            if (j == -1)
                ai->trans = 256;
            else
                ai->trans = j;
            ai->blending_mode = readInt();
            ai->calcAffineMatrix();
        }
        
        readInt();
        readInt();
        if (file_version >= 205) readInt(); // 1
        readInt();
        readInt();
        readInt();
        readInt();
        if (file_version >= 205) readChar(); // 0
    }

    if (file_version >= 206){
        readInt(); // 0
        readInt(); // 160
        readInt(); // 320
        readInt(); // 480
        if (file_version >= 207)
            underline_value = readInt();
        else
            readInt(); // 480
    }
    
    int text_num = readInt();
    start_page = current_page;
    for ( i=0 ; i<text_num ; i++ ){
        clearCurrentPage();
        do{
            current_page->text[current_page->text_count] = readChar();
        }
        while( current_page->text[current_page->text_count++] );
        if (file_version == 203) readChar(); // 0
        current_page->text_count--;
        current_page = current_page->next;
    }
    clearCurrentPage();

    if (file_version >= 205){
        Page *page = start_page;
        j = readInt();
        for (i=0 ; i<j ; i++){
            readStr(&page->tag);
            page = page->next;
        }
    }
    else if (file_version >= 204){
        readInt();
        readInt();
    }
    
    i = readInt();
    current_label_info = script_h.getLabelByLine( i );
    current_line = i - current_label_info.start_line;
    //printf("load %d:%d(%d-%d)\n", current_label_info.start_line, current_line, i, current_label_info.start_line);
    char *buf = script_h.getAddressByLine( i );
    
    j = readInt();
    for ( i=0 ; i<j ; i++ ){
        while( *buf != ':' ) buf++;
        buf++;
    }
    script_h.setCurrent( buf );

    display_mode = shelter_display_mode = DISPLAY_MODE_TEXT;
    clickstr_state = CLICK_NONE;
    draw_cursor_flag = false;
    
    return 0;
}
Exemplo n.º 28
0
int main(int argc, char* args[])
{
		srand(time(NULL));
		PLAYER* player = createPlayer();
		BACKGROUND* background = createBackground();

    LTexture lt;
		BANANA* bananaArray[MAX_NUM_OF_BANANA];
		BARRIER* barrierArray[MAX_NUM_OF_BARRIER];

		int i;
		for(i = 0; i < MAX_NUM_OF_BANANA; i++)
		{
				bananaArray[i] = createBanana();
		}

		for(i = 0; i < MAX_NUM_OF_BARRIER; i++)
		{
				barrierArray[i] = createBarrier();
		}


		if( !init() )
		{
			printf( "Failed to initialize!\n" );
		}
		else
		{

			if( !loadBackground("./media/background.png", &background->background_tex, gRenderer) || !loadPlayer("./media/minion.png", &player->player_tex, gRenderer, gSpriteClips))
			{
      	printf( "Failed to load media!\n" );
			}
			else
			{
				for(i = 0; i < MAX_NUM_OF_BANANA; i++)
				{
						loadBanana("./media/banana.png", &bananaArray[i]->banana_tex, gRenderer);
						setPosRectBanana(bananaArray[i]);
				}

				for(i = 0; i < MAX_NUM_OF_BARRIER; i++)
				{
						loadBarrier("./media/barrier.png", &barrierArray[i]->barrier_tex, gRenderer);
						setPosRectBarrier(barrierArray[i]);
				}

				bool quit = false;
				SDL_Event e;
				player->frame = 0;
				background->scrollingOffset = 0;

				while( !quit )
				{
					while( SDL_PollEvent( &e ) != 0 )
					{
						if( e.type == SDL_QUIT )
						{
							quit = true;
						}

						if(e.key.type == SDL_KEYDOWN)
						{
							switch( e.key.keysym.sym )
							{
									case SDLK_UP:
										if(canMoveUp(player))
										{
											moveUp(player);
										}
										 break;
									case SDLK_DOWN:
										if(canMoveDown(player))
										{
											moveDown(player);
										}
										break;
							}
						}


					}

					--(background->scrollingOffset);
					if( background->scrollingOffset < -background->background_tex.mWidth )
					{
						background->scrollingOffset = 0;
					}

					SDL_Rect* currentClip;

					SDL_SetRenderDrawColor( gRenderer, 0xFF, 0xFF, 0xFF, 0xFF );
					SDL_RenderClear( gRenderer );
					renderBackground(background, background->scrollingOffset, gRenderer);

					currentClip = &gSpriteClips[ player->frame / 16 ];
					renderPlayer(player, currentClip, gRenderer);
					setPosRectPlayer(player);

					for (i = 0; i < MAX_NUM_OF_BANANA; i++)
					{
						if( checkCollision(player->mPlayer, bananaArray[i]->mBanana, background->scrollingOffset))
						{
							increaseTotalScore();
							eraseBanana(bananaArray[i]);
						}

						renderBanana(bananaArray[i], background->scrollingOffset + bananaArray[i]->posX, gRenderer);
					}



					for (i = 0; i < MAX_NUM_OF_BARRIER; i++)
					{
						if( checkCollisionEnd(player->mPlayer, barrierArray[i]->mBarrier, background->scrollingOffset))
						{
							closeWin(player, background, bananaArray, barrierArray);
							return 0;
						}

						renderBarrier(barrierArray[i], background->scrollingOffset + barrierArray[i]->posX, gRenderer);
					}



					++player->frame;

					if( player->frame / 4 >= WALKING_ANIMATION_FRAMES )
					{
						player->frame = 0;
					}


					SDL_RenderPresent(gRenderer);


				}
					closeWin(player, background, bananaArray, barrierArray);

			}
		}
		return 0;
}
int ONScripterLabel::loadSaveFile2( int file_version )
{
    deleteNestInfo();
    
    int i, j;
    
    readInt(); // 1
    if ( readInt() == 1 ) sentence_font.is_bold = true;
    else                  sentence_font.is_bold = false;
    if ( readInt() == 1 ) sentence_font.is_shadow = true;
    else                  sentence_font.is_shadow = false;

    readInt(); // 0
    rmode_flag = (readInt()==1)?true:false;
    sentence_font.color[0] = readInt();
    sentence_font.color[1] = readInt();
    sentence_font.color[2] = readInt();
    cursor_info[0].remove();
    readStr( &cursor_info[0].image_name );
    if ( cursor_info[0].image_name ){
        parseTaggedString( &cursor_info[0] );
        setupAnimationInfo( &cursor_info[0] );
        if ( cursor_info[0].image_surface )
            cursor_info[0 ].visible = true;
    }
    cursor_info[1].remove();
    readStr( &cursor_info[1].image_name );
    if ( cursor_info[1].image_name ){
        parseTaggedString( &cursor_info[1] );
        setupAnimationInfo( &cursor_info[1] );
        if ( cursor_info[1].image_surface )
            cursor_info[1 ].visible = true;
    }

    window_effect.effect = readInt();
    window_effect.duration = readInt();
    readStr( &window_effect.anim.image_name ); // probably

    sentence_font.clear();
    sentence_font.ttf_font  = NULL;
    sentence_font.top_xy[0] = readInt();
    sentence_font.top_xy[1] = readInt();
#ifndef RCA_SCALE
    sentence_font.num_xy[0] = readInt();
    sentence_font.num_xy[1] = readInt();
#else
    sentence_font.num_xy[0] = readInt() * scr_stretch_x;
    sentence_font.num_xy[1] = readInt() * scr_stretch_y;
#endif
    sentence_font.font_size_xy[0] = readInt();
    sentence_font.font_size_xy[1] = readInt();
    sentence_font.pitch_xy[0] = readInt();
    sentence_font.pitch_xy[1] = readInt();
    for ( i=0 ; i<3 ; i++ )
        sentence_font.window_color[2-i] = readChar();
    if ( readChar() == 0x00 ) sentence_font.is_transparent = true;
    else                      sentence_font.is_transparent = false;
    sentence_font.wait_time = readInt();
    sentence_font_info.pos.x = readInt() * screen_ratio1 / screen_ratio2;
    sentence_font_info.pos.y = readInt() * screen_ratio1 / screen_ratio2;
#ifndef RCA_SCALE
    sentence_font_info.pos.w = (readInt() + 1 - sentence_font_info.pos.x * screen_ratio1 / screen_ratio2) * screen_ratio1 / screen_ratio2;
    sentence_font_info.pos.h = (readInt() + 1 - sentence_font_info.pos.y * screen_ratio1 / screen_ratio2) * screen_ratio1 / screen_ratio2;
#else
    sentence_font_info.pos.w = (readInt() + 1 - sentence_font_info.pos.x * screen_ratio1 / screen_ratio2) * screen_ratio1 * scr_stretch_x / screen_ratio2;
    sentence_font_info.pos.h = (readInt() + 1 - sentence_font_info.pos.y * screen_ratio1 / screen_ratio2) * screen_ratio1 * scr_stretch_y / screen_ratio2;
#endif
    readStr( &sentence_font_info.image_name );
    if ( !sentence_font.is_transparent && sentence_font_info.image_name ){
        parseTaggedString( &sentence_font_info );
        setupAnimationInfo( &sentence_font_info );
    }

    if ( readInt() == 1 ) cursor_info[0].abs_flag = false;
    else                  cursor_info[0].abs_flag = true;
    if ( readInt() == 1 ) cursor_info[1].abs_flag = false;
    else                  cursor_info[1].abs_flag = true;
    cursor_info[0].pos.x = readInt() * screen_ratio1 / screen_ratio2;
    cursor_info[1].pos.x = readInt() * screen_ratio1 / screen_ratio2;
    cursor_info[0].pos.y = readInt() * screen_ratio1 / screen_ratio2;
    cursor_info[1].pos.y = readInt() * screen_ratio1 / screen_ratio2;

    // load background surface
    bg_info.remove();
    readStr( &bg_info.file_name );
    createBackground();

    for ( i=0 ; i<3 ; i++ ){
        tachi_info[i].remove();
        readStr( &tachi_info[i].image_name );
        if ( tachi_info[i].image_name ){
            parseTaggedString( &tachi_info[i] );
            setupAnimationInfo( &tachi_info[i] );
#ifdef RCA_SCALE

            if (scr_stretch_y > 1.0) {
                // RCA: Stretch characters to screen size.
                // Note all stretches are with Y-scale, so they don't get distorted (FIXME assumes widescreen)
                SDL_Surface* src = tachi_info[i].image_surface;
                SDL_PixelFormat *fmt = src->format;
                SDL_Surface* dst = SDL_CreateRGBSurface( SDL_SWSURFACE,
                                                         scr_stretch_y*src->w,
                                                         scr_stretch_y*src->h,
                                                         fmt->BitsPerPixel, fmt->Rmask, fmt->Gmask, fmt->Bmask, fmt->Amask );
                resizeSurface( src, dst );
                tachi_info[i].image_surface = dst;
                tachi_info[i].pos.w = src->w*scr_stretch_y;
                tachi_info[i].pos.h = src->h*scr_stretch_y;
                SDL_FreeSurface( src );
            }
#endif
        }
    }

#ifndef RCA_SCALE
    for ( i=0 ; i<3 ; i++ ) 
        tachi_info[i].pos.x = readInt() * screen_ratio1 / screen_ratio2;
#else
    for ( i=0 ; i<3 ; i++ ) {
	readInt();
        tachi_info[i].pos.x = screen_width * (i+1) / 4 - tachi_info[i].pos.w / 2;  // RCA Ignore saved value
    }
#endif

#ifndef RCA_SCALE
    for ( i=0 ; i<3 ; i++ )
        tachi_info[i].pos.y = readInt() * screen_ratio1 / screen_ratio2;
#else
    for ( i=0 ; i<3 ; i++ ) {
	readInt();
        if (tachi_info[i].image_surface)
            tachi_info[i].pos.y = underline_value - tachi_info[i].image_surface->h + 1;  // RCA Ignore saved value
    }
#endif

    readInt(); // 0
    readInt(); // 0
    readInt(); // 0

    if (file_version >= 203){
        readInt(); // -1
        readInt(); // -1
        readInt(); // -1
    }
    
    for ( i=0 ; i<MAX_SPRITE_NUM ; i++ ){
        sprite_info[i].remove();
        readStr( &sprite_info[i].image_name );
        if ( sprite_info[i].image_name ){
            parseTaggedString( &sprite_info[i] );
            setupAnimationInfo( &sprite_info[i] );
        }
        sprite_info[i].pos.x = readInt() * screen_ratio1 / screen_ratio2;
        sprite_info[i].pos.y = readInt() * screen_ratio1 / screen_ratio2;
        if ( readInt() == 1 ) sprite_info[i].visible = true;
        else                  sprite_info[i].visible = false;
        sprite_info[i].current_cell = readInt();
	if (file_version >= 203) {
            int trans = readInt();
            if (trans == -1)
                trans = 256;
            sprite_info[i].trans = trans;
        }
    }

    readVariables( 0, script_h.global_variable_border );

    // nested info
    int num_nest =readInt();
    last_nest_info = &root_nest_info;
    if (num_nest > 0){
        file_io_buf_ptr += (num_nest-1)*4;
        while( num_nest > 0 ){
            NestInfo *info = new NestInfo();
            if (last_nest_info == &root_nest_info) last_nest_info = info;
        
            i = readInt();
            if (i > 0){
                info->nest_mode = NestInfo::LABEL;
                info->next_script = script_h.getAddress( i );
                file_io_buf_ptr -= 8;
                num_nest--;
            }
            else{
                info->nest_mode = NestInfo::FOR;
                info->next_script = script_h.getAddress( -i );
                file_io_buf_ptr -= 16;
                info->var_no = readInt();
                info->to = readInt();
                info->step = readInt();
                file_io_buf_ptr -= 16;
                num_nest -= 4;
            }
            info->next = root_nest_info.next;
            if (root_nest_info.next) root_nest_info.next->previous = info;
            root_nest_info.next = info;
            info->previous = &root_nest_info;
        }
        num_nest = readInt();
        file_io_buf_ptr += num_nest*4;
    }

    if (readInt() == 1) monocro_flag = true;
    else                monocro_flag = false;
    for ( i=0 ; i<3 ; i++ )
        monocro_color[2-i] = readInt();
    for ( i=0 ; i<256 ; i++ ){
        monocro_color_lut[i][0] = (monocro_color[0] * i) >> 8;
        monocro_color_lut[i][1] = (monocro_color[1] * i) >> 8;
        monocro_color_lut[i][2] = (monocro_color[2] * i) >> 8;
    }
    nega_mode = readInt();
    
    // ----------------------------------------
    // Sound
    stopCommand();
    loopbgmstopCommand();
    stopAllDWAVE();

    readStr( &midi_file_name ); // MIDI file
    readStr( &wave_file_name ); // wave, waveloop
    i = readInt();
    if ( i >= 0 ) current_cd_track = i;

    // play, playonce MIDI
    if ( readInt() == 1 ){
        midi_play_loop_flag = true;
        current_cd_track = -2;
        playSound(midi_file_name, SOUND_MIDI, midi_play_loop_flag);
    }
    else
        midi_play_loop_flag = false;
    
    // wave, waveloop
    if ( readInt() == 1 ) wave_play_loop_flag = true;
    else                  wave_play_loop_flag = false;
    if ( wave_file_name && wave_play_loop_flag )
        playSound(wave_file_name, SOUND_WAVE|SOUND_OGG, wave_play_loop_flag, MIX_WAVE_CHANNEL);

    // play, playonce
    if ( readInt() == 1 ) cd_play_loop_flag = true;
    else                  cd_play_loop_flag = false;
    if ( current_cd_track >= 0 ) playCDAudio();

    // bgm, mp3, mp3loop
    if ( readInt() == 1 ) music_play_loop_flag = true;
    else                  music_play_loop_flag = false;
    if ( readInt() == 1 ) mp3save_flag = true;
    else                  mp3save_flag = false;
    readStr( &music_file_name );
    if ( music_file_name ){
        playSound(music_file_name,
                  SOUND_WAVE | SOUND_OGG_STREAMING | SOUND_MP3 | SOUND_MIDI,
                  music_play_loop_flag, MIX_BGM_CHANNEL);
    }

    erase_text_window_mode = readInt();
    readInt(); // 1

    barclearCommand();
    for ( i=0 ; i<MAX_PARAM_NUM ; i++ ){
        j = readInt();
        if ( j != 0 ){
            bar_info[i] = new AnimationInfo();
            bar_info[i]->trans_mode = AnimationInfo::TRANS_COPY;
            bar_info[i]->num_of_cells = 1;

            bar_info[i]->param = j;
            bar_info[i]->pos.x = readInt() * screen_ratio1 / screen_ratio2;
            bar_info[i]->pos.y = readInt() * screen_ratio1 / screen_ratio2;
            bar_info[i]->max_width = readInt() * screen_ratio1 / screen_ratio2;
            bar_info[i]->pos.h = readInt() * screen_ratio1 / screen_ratio2;
            bar_info[i]->max_param = readInt();
            for ( j=0 ; j<3 ; j++ )
                bar_info[i]->color[2-j] = readChar();
            readChar(); // 0x00

            int w = bar_info[i]->max_width * bar_info[i]->param / bar_info[i]->max_param;
            if ( bar_info[i]->max_width > 0 && w > 0 ){
                bar_info[i]->pos.w = w;
                bar_info[i]->allocImage( bar_info[i]->pos.w, bar_info[i]->pos.h );
                bar_info[i]->fill( bar_info[i]->color[0], bar_info[i]->color[1], bar_info[i]->color[2], 0xff );
            }
        }
        else{
            readInt(); // -1
            readInt(); // 0
            readInt(); // 0
            readInt(); // 0
            readInt(); // 0
            readInt(); // 0
        }
    }

    prnumclearCommand();
    for ( i=0 ; i<MAX_PARAM_NUM ; i++ ){
        j = readInt();
        if ( prnum_info[i] ){
            prnum_info[i] = new AnimationInfo();
            prnum_info[i]->trans_mode = AnimationInfo::TRANS_STRING;
            prnum_info[i]->num_of_cells = 1;
            prnum_info[i]->color_list = new uchar3[1];

            prnum_info[i]->param = j;
            prnum_info[i]->pos.x = readInt() * screen_ratio1 / screen_ratio2;
            prnum_info[i]->pos.y = readInt() * screen_ratio1 / screen_ratio2;
            prnum_info[i]->font_size_xy[0] = readInt();
            prnum_info[i]->font_size_xy[1] = readInt();
            for ( j=0 ; j<3 ; j++ )
                prnum_info[i]->color_list[0][2-j] = readChar();
            readChar(); // 0x00

            char num_buf[7];
            script_h.getStringFromInteger( num_buf, prnum_info[i]->param, 3 );
            setStr( &prnum_info[i]->file_name, num_buf );

            setupAnimationInfo( prnum_info[i] );
        }
        else{
            readInt(); // -1
            readInt(); // 0
            readInt(); // 0
            readInt(); // 0
            readInt(); // 0
        }
    }

    readInt(); // 1
    readInt(); // 0
    readInt(); // 1
    btndef_info.remove();
    readStr( &btndef_info.image_name );
    if ( btndef_info.image_name && btndef_info.image_name[0] != '\0' ){
        parseTaggedString( &btndef_info );
        setupAnimationInfo( &btndef_info );
        SDL_SetAlpha( btndef_info.image_surface, DEFAULT_BLIT_FLAG, SDL_ALPHA_OPAQUE );
    }

    if ( file_version >= 202 )
        readArrayVariable();
    
    readInt(); // 0
    if ( readChar() == 1 ) erase_text_window_mode = 2;
    readChar(); // 0
    readChar(); // 0
    readChar(); // 0
    readStr( &loop_bgm_name[0] );
    readStr( &loop_bgm_name[1] );
    if ( loop_bgm_name[0] ) {
        if ( loop_bgm_name[1] )
            playSound(loop_bgm_name[1],
                      SOUND_PRELOAD|SOUND_WAVE|SOUND_OGG, false, MIX_LOOPBGM_CHANNEL1);
        playSound(loop_bgm_name[0],
                  SOUND_WAVE|SOUND_OGG, false, MIX_LOOPBGM_CHANNEL0);
    }

    if ( file_version >= 201 ){
        if ( readInt() == 1 ) rubyon_flag = true;
        else                  rubyon_flag = false;
        ruby_struct.font_size_xy[0] = readInt();
        ruby_struct.font_size_xy[1] = readInt();
        readStr( &ruby_struct.font_name );
        sentence_font.setRubyOnFlag(rubyon_flag);
    }

    if (file_version >= 204){
        readInt();
        
        for ( i=0 ; i<MAX_SPRITE2_NUM ; i++ ){
            sprite2_info[i].remove();
            readStr( &sprite2_info[i].image_name );
            if ( sprite2_info[i].image_name ){
                parseTaggedString( &sprite2_info[i] );
                setupAnimationInfo( &sprite2_info[i] );
            }
            sprite2_info[i].pos.x = readInt() * screen_ratio1 / screen_ratio2;
            sprite2_info[i].pos.y = readInt() * screen_ratio1 / screen_ratio2;
            sprite2_info[i].scale_x = readInt();
            sprite2_info[i].scale_y = readInt();
            sprite2_info[i].rot = readInt();
            if ( readInt() == 1 ) sprite2_info[i].visible = true;
            else                  sprite2_info[i].visible = false;
            j = readInt();
            if (j == -1)
                sprite2_info[i].trans = 256;
            else
                sprite2_info[i].trans = j;
            sprite2_info[i].blending_mode = readInt();
            sprite2_info[i].calcAffineMatrix();
        }
        
        readInt();
        readInt();
        if (file_version >= 205) readInt(); // 1
        readInt();
        readInt();
        readInt();
        readInt();
        if (file_version >= 205) readChar(); // 0
    }

    if (file_version >= 206){
        readInt(); // 0
        readInt(); // 160
        readInt(); // 320
        readInt(); // 480
        readInt(); // 480
    }

    int text_num = readInt();
    //Mion: clearing page then moving to next eliminates buffer error
    start_page = current_page->next;
    clearCurrentPage();
    current_page = start_page;
    for ( i=0 ; i<text_num ; i++ ){
        clearCurrentPage();
        do{
            current_page->text[current_page->text_count] = readChar();
        }
        while( current_page->text[current_page->text_count++] );
	if (file_version == 203) readChar(); // 0
        current_page->text_count--;
        current_page = current_page->next;
    }
    clearCurrentPage();

    if (file_version >= 205){
        Page *page = start_page;
        j = readInt();
        for (i=0 ; i<j ; i++){
            readStr(&page->tag);
            page = page->next;
        }
    }
    else if (file_version >= 204){
        readInt();
        readInt();
    }
    
    i = readInt();
    current_label_info = script_h.getLabelByLine( i );
    current_line = i - current_label_info.start_line;
    //printf("load %d:%d(%d-%d)\n", current_label_info.start_line, current_line, i, current_label_info.start_line);
    char *buf = script_h.getAddressByLine( i );
    
    j = readInt();
    for ( i=0 ; i<j ; i++ ){
        while( *buf != ':' ) buf++;
        buf++;
    }
    script_h.setCurrent( buf );

    display_mode = shelter_display_mode = DISPLAY_MODE_NORMAL;

    clickstr_state = CLICK_NONE;
    event_mode = 0;//WAIT_SLEEP_MODE;
    draw_cursor_flag = false;
    
    return 0;
}
Exemplo n.º 30
0
void MapView::updateMap()
{
    setPixmap( createBackground() );
}