Ejemplo n.º 1
0
ItemEditorWidget::ItemEditorWidget(ItemWidget *itemWidget, const QModelIndex &index,
                                   bool editNotes, QWidget *parent)
    : QWidget(parent)
    , m_itemWidget(itemWidget)
    , m_index(index)
    , m_editor(NULL)
    , m_noteEditor(NULL)
    , m_toolBar(NULL)
    , m_saveOnReturnKey(false)
{
    m_noteEditor = editNotes ? new QPlainTextEdit(parent) : NULL;
    QWidget *editor = editNotes ? m_noteEditor : createEditor(itemWidget);

    if (editor == NULL) {
        m_itemWidget = NULL;
    } else {
        connect( m_itemWidget->widget(), SIGNAL(destroyed()),
                 this, SLOT(onItemWidgetDestroyed()) );
        initEditor(editor);
        if (m_noteEditor != NULL)
            m_noteEditor->setPlainText( index.data(contentType::notes).toString() );
        else
            itemWidget->setEditorData(editor, index);
    }
}
Ejemplo n.º 2
0
Editor::Editor()
{
	paintedNode = new vector<ISceneNode *>(0);
	initEditor();
	vFirst = vector3df(0, 0, 0);
	vLast = vector3df(0, 0, 0);
#ifdef EDITOR_VIEW
	initEditorView();
#endif
}
Ejemplo n.º 3
0
int main(int argc, char **argv) {
  // takdit <ファイル名> という引数のみ実行
  if (argc != 2) {
    fprintf(stderr, "Usage: takdit <filename>\n");
    exit(1);
  }

  initEditor();                         // エディタの初期化
  editorSelectSyntaxHighlight(argv[1]); // シンタックスハイライトの適用
  editorOpen(argv[1]);                  // ファイルを開く
  enableRawMode(STDIN_FILENO);          // Rawモードの有効化
  editorSetStatusMessage(
      "HELP: Ctrl-S = save | Ctrl-Q = quit | Ctrl-F = find");
  while (1) {
    editorRefreshScreen();                // 変更の反映
    editorProcessKeypress(STDIN_FILENO);  // キー入力待ち
  }
  return 0;
}
Ejemplo n.º 4
0
int main(int argc, char **argv) {
    NOTUSED(argc);
    NOTUSED(argv);

    initConfig();
    parseOptions(argc,argv);
    initScreen();
    initEditor(l81.fb,30,30,30,30);
    editorOpen(l81.filename);
    while(1) {
        resetProgram();
        loadProgram();
        if (!l81.luaerr) {
            SDL_setFramerate(&l81.fb->fps_mgr,l81.fps);
            l81.start_ms = mstime();
            while(!processSdlEvents());
            if (editorFileWasModified()) editorSave(l81.filename);
        }
        editorRun();
    }
    return 0;
}
Ejemplo n.º 5
0
ItemEditorWidget::ItemEditorWidget(
        const std::shared_ptr<ItemWidget> &itemWidget,
        const QModelIndex &index, bool editNotes, QWidget *parent)
    : QWidget(parent)
    , m_itemWidget(itemWidget)
    , m_index(index)
    , m_editor(nullptr)
    , m_noteEditor(nullptr)
    , m_toolBar(nullptr)
    , m_saveOnReturnKey(false)
{
    m_noteEditor = editNotes ? new QPlainTextEdit(parent) : nullptr;
    QWidget *editor = editNotes ? m_noteEditor : createEditor();

    if (editor == nullptr) {
        m_itemWidget = nullptr;
    } else {
        initEditor(editor);
        if (m_noteEditor != nullptr)
            m_noteEditor->setPlainText( index.data(contentType::notes).toString() );
        else
            itemWidget->setEditorData(editor, index);
    }
}
void Editor::redraw()
{

	if (!isInit)
	{
		initEditor();
		isInit = true;
	}

	vec3f bgColor, gridColor;
	glColor3f( 1.0, 1.0, 1.0 );
	if (!m_level)
	{
		glClearColor( _TV( 0.2f ), _TV(0.0f), _TV( 0.0f ), 1.0 );
		glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

		gfEnableFont( m_fntFontId, 32 );	
		gfBeginText();
		glTranslated( _TV(260), _TV(550), 0 );
		gfDrawString( "No Level Active" );
		gfEndText();
	}
	else
	{
		bgColor = m_level->m_bgColor;
		gridColor = (bgColor + vec3f( 1.0f, 1.0f, 1.0f )) / 2.0f;

		glClearColor( bgColor.r, bgColor.g, bgColor.b, 1.0 );
		glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
	}


	// at this point we need a level to draw
	if (m_level)
	{
		// reset the view to be map space
		glMatrixMode( GL_PROJECTION );
		glLoadIdentity();

		if (m_useEditView)
		{
			gluOrtho2D( m_viewport.x, m_viewport.x + m_viewsize.x, 
				m_viewport.y, m_viewport.y + m_viewsize.y ) ;
		}
		else
		{
			pseudoOrtho2D( m_gameview.x, m_gameview.x + 800,
				m_gameview.y, m_gameview.y + 600 );
		}

		glMatrixMode( GL_MODELVIEW );
		glLoadIdentity();
		
		// Draw the level grid
		float zval = _TV( -0.5f );
		glColor3f( gridColor.r, gridColor.g, gridColor.b );
		glDisable( GL_TEXTURE );

		glLineWidth( 2.0f );
		glBegin( GL_LINE_LOOP );
		glVertex3f( 0.0, 0.0, zval );
		glVertex3f( m_level->m_mapSize.x, 0.0, zval );
		glVertex3f( m_level->m_mapSize.x, m_level->m_mapSize.y, zval );
		glVertex3f( 0.0, m_level->m_mapSize.y, zval );	
		glEnd();


		// draw grid lines
		glLineWidth( 1.0f );
		glBegin( GL_LINES );
		for (float xpos=800; xpos < m_level->m_mapSize.x; xpos += 800.0)
		{
			glVertex3f( xpos, 0.0, zval );
			glVertex3f( xpos, m_level->m_mapSize.y, zval );
		}

		for (float ypos = 600; ypos < m_level->m_mapSize.y; ypos += 600.0)
		{
			glVertex3f( 0.0, ypos, zval);
			glVertex3f( m_level->m_mapSize.x, ypos, zval );
		}
		glEnd();

		glLineWidth( 1.0f );
		glEnable( GL_LINE_STIPPLE );
		glLineStipple( 1, 0xAAAAAAAA );
		glBegin( GL_LINES );
		for (float xpos=100; xpos < m_level->m_mapSize.x; xpos += 100.0)
		{
			glVertex3f( xpos, 0.0, zval );
			glVertex3f( xpos, m_level->m_mapSize.y, zval );
		}

		for (float ypos = 100; ypos < m_level->m_mapSize.y; ypos += 100.0)
		{
			glVertex3f( 0.0, ypos,zval );
			glVertex3f( m_level->m_mapSize.x, ypos, zval );
		}
		glEnd();
		glDisable( GL_LINE_STIPPLE );		

		// draw the "game view" extents
		if (m_useEditView)
		{
			glLineWidth( 2.0f );
			glColor3f( 0.7f, 0.4f, 0.7f );

			glPushMatrix();
			glTranslated( m_gameview.x, m_gameview.y, 0.0 );

			glBegin( GL_LINE_LOOP );
			glVertex3f( 0.0, 0.0, 0.0 );
			glVertex3f( 800, 0.0, 0.0 );
			glVertex3f( 800, 600, 0.0 );
			glVertex3f( 0.0, 600, 0.0 );			
			glEnd();

			glPopMatrix();
		}

		

		// draw the level
		m_level->draw();
	
		// draw icons		
		glEnable( GL_TEXTURE_2D );
		glDisable( GL_BLEND );
		glEnable( GL_ALPHA_TEST );		
		glAlphaFunc( GL_GREATER, 0.5 );

		iconSpawnPoint->pos = m_level->m_spawnPoint;
		iconSpawnPoint->pos.y += 16.0;
		iconSpawnPoint->drawBraindead();
								
		
		if (drawLine)
		{
			// drawing a line (for collision)
			glDisable( GL_TEXTURE_2D );
			
			vec3f col = segColor( currSegType );
			glColor3f( col.r, col.g, col.b );

			glLineWidth( 5 );
			glBegin( GL_LINES );
			glVertex3f( m_dragStart.x, m_dragStart.y, 0.0 );
			glVertex3f( m_mousePos.x, m_mousePos.y, 0.0 );
			glEnd();

			glColor3f( 1.0f, 1.0f, 1.0f );
		} 
		else if (m_activeShape)
		{
			// draw the active shape (aka "cursor")		
			glEnable( GL_TEXTURE_2D );
			if (m_activeShape->blendMode == Blend_OFF)
			{
				glDisable( GL_BLEND );
				glEnable( GL_ALPHA_TEST );
				glAlphaFunc( GL_GREATER, 0.5 );
			}
			else
			{
				glEnable( GL_BLEND );
				glDisable( GL_ALPHA_TEST );
				glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );		
			}

			m_activeShape->sortNum = m_sort;
			m_activeShape->drawBraindead();			
		}				
	
	}

	// draw regular collision lines
	if (m_level)
	{
		glDisable( GL_TEXTURE_2D );
		glColor3f( 1.0f, 1.0f, 0.5f );
		glLineWidth( 3 );
			
		glBegin( GL_LINES );
		for (int i=0; i < m_level->m_collision.size(); i++)
		{
			Segment &s = m_level->m_collision[i];
			vec3f col = segColor( s.segType );
			glColor3f( col.r, col.g, col.b );

			glVertex3f( s.a.x, s.a.y, 0.0 );
			glVertex3f( s.b.x, s.b.y, 0.0 );		
			
		}		
		glEnd();
	}

	// now draw any text overlay		
	if (m_showHelp)
	{
		glColor3f( 1.0f, 1.0f, 1.0f );
		gfEnableFont( m_fntFontId, 20 );	
		gfBeginText();
		glTranslated( _TV(50), _TV(500), 0 );
		
		gfDrawString( "------[ EDITOR KEYS ]------\n" 
			          "h - toggle this help\n" 
					  "F2 - save level\n"
					  "F3 - load level\n"
	    			  "1,2,3 - New Level (small, med, large)\n" 					  
					  "f - frame view\n" 
					  "<,> - select brush\n" 
					  "TAB - toggle editor/closeup\n" 
					  "ARROWS - move view\n"
					  "a,z,s,x - change sort\n"
					  "o,p,brackets - brush size\n"
					  "k,l - zoom view\n" 
					  "8,9 - segment type\n"
					  "0 - spawn point\n"
					  "mousewheel - rotate brush\n"
					  "SPC, LMB - stamp brush\n"
					  "Drag RMB - draw segment\n"
					  );			
		gfEndText();
	}	

	// draw the active shape info
	if (m_activeShape)
	{
		glEnable( GL_TEXTURE_2D );		

		glColor3f( 1.0f, 1.0f, 1.0f );

		gfEnableFont( m_fntFontId, 20 );	
		gfBeginText();
		glTranslated( _TV(650), _TV(570), 0 );		
		
		gfDrawStringFmt( "%s (%d)",
				m_activeShape->name.c_str(),
				m_sort );
		gfEndText();

		vec3f col = segColor( currSegType );
		glColor3f( col.r, col.g, col.b );
		gfBeginText();
		glTranslated( _TV(650), _TV(550), 0 );		
				
		gfDrawString( SegTypeNames[ currSegType ] );

		gfEndText();
		
		glDisable( GL_TEXTURE_2D );
	}
}