void ONScripterLabel::executeWindowErase()
{
    if (windowchip_sprite_no >= 0)
        sprite_info[windowchip_sprite_no].visible = false;

#if 0 //windoweffect w/windowerase broken currently FIXME
    refreshSurface(effect_dst_surface, NULL,
                   mode_saya_flag ? REFRESH_SAYA_MODE : REFRESH_NORMAL_MODE);

    //use the windoweffect when executing the erase
    int shelter_menu_mode = system_menu_mode;
    system_menu_mode = SYSTEM_NULL;  //prevents infinite event looping
    if (!setEffect(&window_effect, false, false)) {
        while(doEffect(&window_effect, false));
    }
    system_menu_mode = shelter_menu_mode;
#else
    display_mode = DISPLAY_MODE_NORMAL;
    flush(mode_saya_flag ? REFRESH_SAYA_MODE : REFRESH_NORMAL_MODE);
#endif

    event_mode = WAIT_TIMER_MODE | WAIT_BUTTON_MODE;
    waitEventSub(-1);

    if (windowchip_sprite_no >= 0)
        sprite_info[windowchip_sprite_no].visible = true;

    leaveSystemCall();
}
int PonscripterLabel::leaveTextDisplayMode(bool force_leave_flag)
{
    if (!force_leave_flag && (skip_flag || draw_one_page_flag || ctrl_pressed_status)) {
        did_leavetext = true;
        return RET_NOMATCH;
    }
    if (force_leave_flag) did_leavetext = false;

    if (!did_leavetext && (display_mode & TEXT_DISPLAY_MODE) &&
        (force_leave_flag || (erase_text_window_mode != 0))) {

        if (event_mode & EFFECT_EVENT_MODE) {
            if (doEffect(window_effect, false) == RET_CONTINUE) {
                display_mode = NORMAL_DISPLAY_MODE;
                return RET_CONTINUE | RET_NOREAD;
            }

            return RET_WAIT | RET_REREAD;
        }
        else {
            dirty_rect.add(sentence_font_info.pos);
            refreshSurface(backup_surface, &dirty_rect.bounding_box, REFRESH_NORMAL_MODE);
            SDL_BlitSurface(backup_surface, NULL, effect_dst_surface, NULL);
            SDL_BlitSurface(accumulation_surface, NULL, backup_surface, NULL);

            return setEffect(window_effect, false, false);
        }
    }

    return RET_NOMATCH;
}
int PonscripterLabel::enterTextDisplayMode(bool text_flag)
{
    if (line_enter_status <= 1 && saveon_flag && internal_saveon_flag &&
    text_flag && current_read_language == 1) {
        saveSaveFile(-1);
        internal_saveon_flag = false;
    }

    did_leavetext = false;
    if (!(display_mode & TEXT_DISPLAY_MODE)) {
        if (event_mode & EFFECT_EVENT_MODE) {
            if (doEffect(window_effect, false) == RET_CONTINUE) {
                display_mode = TEXT_DISPLAY_MODE;
                text_on_flag = true;
                return RET_CONTINUE | RET_NOREAD;
            }
            return RET_WAIT | RET_REREAD;
        }
        else {
            dirty_rect.clear();
            dirty_rect.add(sentence_font_info.pos);
            refreshSurface(effect_dst_surface, NULL, refresh_shadow_text_mode);

            return setEffect(window_effect, false, true);
        }
    }

    return RET_NOMATCH;
}
int ONScripterLabel::enterTextDisplayMode(bool text_flag)
{
    if (line_enter_status <= 1 && saveon_flag && internal_saveon_flag && text_flag){
        saveSaveFile( -1 );
        internal_saveon_flag = false;
    }
    
    if ( !(display_mode & TEXT_DISPLAY_MODE) ){
        if ( event_mode & EFFECT_EVENT_MODE ){
            if ( doEffect( &window_effect, NULL, DIRECT_EFFECT_IMAGE, false ) == RET_CONTINUE ){
                display_mode = TEXT_DISPLAY_MODE;
                text_on_flag = true;
                return RET_CONTINUE | RET_NOREAD;
            }
            return RET_WAIT | RET_REREAD;
        }
        else{
            SDL_BlitSurface( accumulation_comp_surface, NULL, effect_dst_surface, NULL );
            SDL_BlitSurface( accumulation_surface, NULL, accumulation_comp_surface, NULL );
            dirty_rect.clear();
            dirty_rect.add( sentence_font_info.pos );

            return setEffect( &window_effect );
        }
    }
    
    return RET_NOMATCH;
}
Exemplo n.º 5
0
void CastEffect::startTicks()
{
	if( m_type == CET_BUFF_STAT || m_type == CET_SUPPRESS_STAT ) {
		doEffect();
	}else {
		m_numTicksCompleted = 0;
		int numTicks = (m_lifeTime / m_tickFreq) + 1;
		CastCommandScheduler::get()->scheduleSelector( schedule_selector(CastEffect::onTick), this, m_tickFreq, numTicks, 0.0f, false);
	}

}
Exemplo n.º 6
0
void ONScripter::leaveTextDisplayMode(bool force_leave_flag)
{
    if (display_mode & DISPLAY_MODE_TEXT &&
        (force_leave_flag || erase_text_window_mode != 0)){

        SDL_BlitSurface(backup_surface, NULL, effect_dst_surface, NULL);
        dirty_rect.add(sentence_font_info.pos);
            
        if (setEffect(&window_effect, false, false)) return;
        while(doEffect(&window_effect, false));

        display_mode = DISPLAY_MODE_NORMAL;
    }
}
void ONScripterLabel::leaveSystemCall( bool restore_flag )
{
    bool tmp = txtbtn_show;
    txtbtn_show = false;

    current_font = &sentence_font;
    key_pressed_flag = false;
    current_button_state.reset();

    if ( restore_flag ){

        current_page = cached_page;
        text_info.deepcopy(shelter_text_info);
        shelter_text_info.reset();
        root_button_link.next = shelter_button_link;
        root_select_link.next = shelter_select_link;
        exbtn_d_button_link = exbtn_d_shelter_button_link;
#if 0 //broken atm
        //use windoweffect on a return from windowerase systemcall
        if (system_menu_mode == SYSTEM_WINDOWERASE) {
            display_mode = shelter_display_mode;
            refreshSurface( effect_dst_surface, NULL, refreshMode() );
            system_menu_mode = SYSTEM_NULL;
            if (!setEffect(&window_effect, false, true)) {
                while(doEffect(&window_effect, false));
            }
        }
#endif
        erasetextbtnCommand();
        event_mode = shelter_event_mode;
        draw_cursor_flag = shelter_draw_cursor_flag;
        if ( event_mode & WAIT_BUTTON_MODE ){
            SDL_WarpMouse( shelter_mouse_state.x, shelter_mouse_state.y );
        }
    }
    display_mode = shelter_display_mode;
    dirty_rect.fill( screen_width, screen_height );
    flush( refreshMode() );

    //printf("leaveSystemCall %d %d\n",event_mode, clickstr_state);

    refreshMouseOverButton();
    txtbtn_show = tmp;

    system_menu_mode = SYSTEM_NULL;
}
Exemplo n.º 8
0
void ONScripter::enterTextDisplayMode(bool text_flag)
{
    if (line_enter_status <= 1 && saveon_flag && internal_saveon_flag && text_flag){
        saveSaveFile( -1 );
        internal_saveon_flag = false;
    }
    
    if (!(display_mode & DISPLAY_MODE_TEXT)){
        refreshSurface( effect_dst_surface, NULL, refresh_shadow_text_mode );
        dirty_rect.clear();
        dirty_rect.add( sentence_font_info.pos );

        if (setEffect(&window_effect, false, true)) return;
        while(doEffect(&window_effect, false));

        display_mode = DISPLAY_MODE_TEXT;
        text_on_flag = true;
    }
}
Exemplo n.º 9
0
void CastEffect::onTick( float dt )
{
	if( !CastWorldModel::get()->isValid( m_pTarget ) ) return;

	double currTime = CastCommandTime::get();
	float delta = currTime - m_startTime;
	if( delta > m_lifeTime ) delta = m_lifeTime;

	if( m_type == CET_SUPPRESS_STAT || m_type == CET_BUFF_STAT ) {
		//handle buff/debuff end
		if( delta == m_lifeTime ) {
			CastCommandScheduler::get()->unscheduleSelector( schedule_selector(CastEffect::onTick), this );
			if( m_type == CET_BUFF_STAT ) {
				m_pTarget->endBuffProperty( m_targetStat, m_value, this );
			}else {
				m_pTarget->endBuffProperty( m_targetStat, -1 * m_value, this );
			}

			m_pTarget->removeEffect(this);
		}
		
	}else {
		//handle dmg/heal over time ticks
		int numTicksPassed = delta / m_tickFreq;

		int ticksToDo = numTicksPassed - m_numTicksCompleted;
		for( int i=0; i< ticksToDo; i++) {
			doEffect();
			m_numTicksCompleted++;
		}

		if( delta >= m_lifeTime ) 
		{
			//NOTE: scheduleSelectors add references to objects, so we have to 
			// cancel our ticks before the object will be cleaned up by autopool
			cancelTicks(); 
			m_pTarget->removeEffect(this);
		}
	}


}
Exemplo n.º 10
0
int ONScripterLabel::leaveTextDisplayMode(bool force_leave_flag)
{
    if ( display_mode & TEXT_DISPLAY_MODE &&
         (force_leave_flag || erase_text_window_mode != 0) ){

        if ( event_mode & EFFECT_EVENT_MODE ){
            if ( doEffect( &window_effect,  NULL, DIRECT_EFFECT_IMAGE, false ) == RET_CONTINUE ){
                display_mode = NORMAL_DISPLAY_MODE;
                return RET_CONTINUE | RET_NOREAD;
            }
            return RET_WAIT | RET_REREAD;
        }
        else{
            SDL_BlitSurface( accumulation_comp_surface, NULL, effect_dst_surface, NULL );
            SDL_BlitSurface( accumulation_surface, NULL, accumulation_comp_surface, NULL );
            dirty_rect.add( sentence_font_info.pos );
            
            return setEffect( &window_effect );
        }
    }
    
    return RET_NOMATCH;
}
Exemplo n.º 11
0
void stinkingRich::InputSystem::update(float deltaTime) {
	if (pressCooldown > 0.0f) {
		pressCooldown -= deltaTime;
	}

	keyStates = SDL_GetKeyboardState(nullptr);

	bool advancePlayer = false;

	int mouseX = 0;
	int mouseY = 0;
	auto buttons = SDL_GetMouseState(&mouseX, &mouseY);

	if (pressCooldown < 0.0f) {
		pressCooldown = -1.0f;

		if (stinkingRich::StinkingRich::uiRenderSystem->checkProcessing()) {
			const auto mouseListeners = engine->getEntitiesFor(ashley::Family::getFor( {
					typeid(MouseListener) }));

			for (const auto &listener : *mouseListeners) {
				const auto &ml = ashley::ComponentMapper<MouseListener>::getMapper().get(listener);
				const auto &message = ml->message;
				const auto &rect = ml->rect;

				if (SDL_BUTTON_LEFT & buttons) {
					if (mouseX >= rect.x && mouseX <= rect.x + rect.w && mouseY >= rect.y
							&& mouseY <= rect.y + rect.h) {
						std::cout << "Got click.\n";
						std::cout.flush();

						switch (message) {
						case MouseMessage::YES: {
							buyProperty();
							if(!getsAnotherGo) advancePlayer = true;
							break;
						}

						case MouseMessage::NO: {
							auctionProperty();
							if(!getsAnotherGo) advancePlayer = true;
							break;
						}

						case MouseMessage::NONE: {
							std::cout << "MouseMessage::NONE Received.\n";
							break;
						}
						}

						stinkingRich::StinkingRich::uiRenderSystem->removeUIEntity();

						pressCooldown = TOTAL_PRESS_COOLDOWN;
						break;
					}
				}
			}
		} else {
			if (keyStates[SDL_SCANCODE_SPACE]) {
				if (!doMove()) {
					if(stinkingRich::StinkingRich::uiRenderSystem->checkProcessing()) {
						advancePlayer = false;
					} else {
						if(!getsAnotherGo) advancePlayer = true;
					}
				}

				pressCooldown = TOTAL_PRESS_COOLDOWN;
			} else if (keyStates[SDL_SCANCODE_F9]) {
				auto c = stinkingRich::StinkingRich::communityChestCards.getTopCard();
				std::cout << c.text << std::endl;
				c.doEffect();
				pressCooldown = TOTAL_PRESS_COOLDOWN;
			} else if (keyStates[SDL_SCANCODE_F10]) {
				auto c = stinkingRich::StinkingRich::chanceCards.getTopCard();
				std::cout << c.text << std::endl;
				c.doEffect();
				pressCooldown = TOTAL_PRESS_COOLDOWN;
			}
		}
	}

	if(advancePlayer) {
		getsAnotherGo = false;
		stinkingRich::StinkingRich::nextPlayer();
	}
}