예제 #1
0
void CEditorView::OnMouseScroll(GdkEventScroll* evt)
{
	GdkScrollDirection i = evt->direction;
	if ( i == GDK_SCROLL_UP )
	{
		GetEditor()->EditorActions(CEditor::Set_Display_Frame_Minus);
		UpdateEditor(); //it's necessary
		GetEditor()->EditorActions(CEditor::Set_Caret_Pos_X);
		UpdateEditor();
		return;
	}

	if ( i == GDK_SCROLL_DOWN )
	{
		GetEditor()->EditorActions(CEditor::Set_Display_Frame_Plus);
		UpdateEditor(); //it's necessary
		GetEditor()->EditorActions(CEditor::Set_Caret_Pos_X);
		UpdateEditor();
		return;
	}
}
예제 #2
0
void CEditorView::OnLButtonDown(GdkEventButton* evt)
{
	CTermView::OnLButtonDown(evt);

	int x = (int)evt->x;
	int y = (int)evt->y;
	PointToLineCol( &x, &y );

	if( !(evt->type == GDK_3BUTTON_PRESS) && !(evt->type == GDK_2BUTTON_PRESS) )
	{
		//set caret to current position
		m_pTermData->m_CaretPos.x = x;
		m_pTermData->m_CaretPos.y = y;
		GetEditor()->EditorActions(CEditor::Set_Caret_Pos_Y);
		GetEditor()->EditorActions(CEditor::Set_Caret_Pos_X);
		UpdateEditor();
	}
}
예제 #3
0
void CEditorView::DoPasteFromClipboard(string text, bool contain_ansi_color)
{
	string locale_str;
	int lines_count = 0, last_line_count = 0;
	if( !ConvStr2SiteEncoding(text, contain_ansi_color, locale_str, lines_count, last_line_count) )
		return;

	int x = m_pTermData->m_CaretPos.x;
	int y = m_pTermData->m_CaretPos.y;

	GetEditor()->EditorActions(CEditor::Paste_To_Editor, locale_str);
	GetEditor()->EditorActions(CEditor::Load_Editor_Text);

	m_pTermData->m_CaretPos.x = lines_count==0 ? x+last_line_count : last_line_count;
	m_pTermData->m_CaretPos.y = y + lines_count;

	UpdateEditor();
}
예제 #4
0
void CEditorView::DoPasteFromClipboard(string text, bool contain_ansi_color)
{
	int x = 0, y = 0, lineCount = 0, foundEndl = -1;
	string tempText = text;
	string colorStart = "\x1b[", colorEnd = "m";
	int ansiCodesLength = 0, foundColorStart = -1, foundColorEnd = -1;

	//handle caret position if paste multiple line text
	while( (foundEndl = tempText.find("\n")) != static_cast<int>(string::npos) )
	{
		tempText = tempText.substr(foundEndl + 1, tempText.length());
		lineCount++;
	}

	x = m_pTermData->m_CaretPos.x + tempText.length();
	y = m_pTermData->m_CaretPos.y + lineCount;

	if( contain_ansi_color )
	{
		string temp = text;
		if( lineCount != 0 )
			temp = tempText; //only take care last line

		//get ansi codes length
		while ( temp.length() > 0 )
		{
			foundColorStart = temp.find(colorStart);
			foundColorEnd = temp.find(colorEnd);
			temp = temp.substr(foundColorEnd + 1, temp.length());
			ansiCodesLength += foundColorEnd - foundColorStart + 1;
		}
		x -= ansiCodesLength;
	}

	GetEditor()->EditorActions(CEditor::Paste_To_Editor, text);
	GetEditor()->EditorActions(CEditor::Load_Editor_Text);
	m_pTermData->m_CaretPos.x = x;
	m_pTermData->m_CaretPos.y = y;
	UpdateEditor();
}
예제 #5
0
	void Tilemap::Render(Entity *entity)
	{
		///HACK:
		UpdateEditor();

		if (this->tileset)
		{
			//Debug::Log("rendering!");
			Graphics::BindTexture(tileset->texture);

			Vector2 texOffset;
			Vector2 texScale = Vector2(tileset->tileWidth / (float)tileset->texture->width, tileset->tileHeight / (float)tileset->texture->height);
			int tilesPerRow = tileset->texture->width / tileset->tileWidth;

			for (int tx = 0; tx < width/tileWidth; tx ++)
			{
				for (int ty = 0; ty < height/tileHeight; ty++)
				{
					int tileID = tiles[(ty*width) + tx];

					//printf("%d, %d = %d", tx, ty, tileID);
					if (tileID != -1)
					{
						//printf("%d, %d = %d", tx, ty, tileID);

						// get x/y coords of tile in tileset
						int tileX = (tileID % tilesPerRow) * tileset->tileWidth;
						int tileY = (tileID / tilesPerRow) * tileset->tileHeight;

						texOffset = Vector2(tileX/(float)tileset->texture->width, tileY/(float)tileset->texture->height);
				
						// render quad with texture coords set
						Graphics::RenderQuad(tileWidth, tileHeight, texOffset, texScale, Vector2(tx * tileWidth + tileWidth*0.5f, ty * tileHeight + tileHeight*0.5f));
					}
				}
			}
		}
	}
예제 #6
0
void Editor::UpdateInput()
{
	GHScreen::UpdateInput();

	// check for main menu
	if(TestControl(dBCtrl_Edit_Menu, GHCT_Once))
		gMenu.Push();

	if(TestControl(dBCtrl_Edit_PopupMenu, GHCT_Once))
		ShowPopupMenu();

	// check for section jump
	if(TestControl(dBCtrl_Edit_Goto, GHCT_Once))
		gpStringBox->Show(MFTranslation_GetString(pStrings, MENU_GOTO), "", GotoSection);

	// update the editor.
	UpdateEditor();

	// enable/disable half time
	if(TestControl(dBCtrl_Edit_PlaybackRate, GHCT_Once))
	{
		bHalfSpeed.data = (bHalfSpeed.data + 1) % (int)(sizeof(gSpeeds) / sizeof(gSpeeds[0]));

		if(gEditor.pSong->pStream)
			MFSound_SetPlaybackRate(MFSound_GetStreamVoice(gEditor.pSong->pStream), gSpeeds[bHalfSpeed]);
		if(gEditor.pSong->pGuitar)
			MFSound_SetPlaybackRate(MFSound_GetStreamVoice(gEditor.pSong->pGuitar), gSpeeds[bHalfSpeed]);
		if(gEditor.pSong->pBass)
			MFSound_SetPlaybackRate(MFSound_GetStreamVoice(gEditor.pSong->pBass), gSpeeds[bHalfSpeed]);
	}

	// swap modes
	if(TestControl(dBCtrl_Edit_StartPlayback, GHCT_Once) || TestControl(dBCtrl_Edit_RestartPlayback, GHCT_Once))
	{
		gEditor.state = GHPS_Playing;

		gEditor.pSong->CalculateNoteTimes(gEditor.currentStream[0], 0);
		if(gEditor.currentStream[1] != -1)
			gEditor.pSong->CalculateNoteTimes(gEditor.currentStream[1], 0);

		if(TestControl(dBCtrl_Edit_RestartPlayback, GHCT_Once))
		{
			gEditor.playbackStartOffset = 0;
			gEditor.playingTime = 0;
		}
		else
		{
			gEditor.playbackStartOffset = gEditor.offset;
			gEditor.playingTime = gEditor.pSong->CalculateTimeOfTick(gEditor.offset);
		}

		gEditor.pSong->Play(gEditor.playingTime);

		gPlay.scoreKeeper[0].Begin(gEditor.pSong, (GHStreams)gEditor.currentStream[0], 0, gEditor.playingTime);
		if(gEditor.currentStream[1] != -1)
			gPlay.scoreKeeper[1].Begin(gEditor.pSong, (GHStreams)gEditor.currentStream[1], 1, gEditor.playingTime);

		if(gEditor.pSong->pStream || gEditor.pSong->pGuitar || gEditor.pSong->pBass)
		{
			gEditor.playStart = 0;
			gEditor.lastTimestamp = 0;
		}
		else
		{
			gEditor.playStart = MFSystem_ReadRTC();
		}
		gEditor.startTime = gEditor.playingTime;

		bSelecting = false;

		Pop();
		gPlay.Push();
	}
}