mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-05-30 18:16:31 +03:00
eepp:
Added Window::showMessageBox. ecode: Closes SpartanJ/ecode#93 (ecode does not properly warn the user of the lack of GPU acceleration). Minor refactor.
This commit is contained in:
@@ -87,8 +87,7 @@ class EE_API TextDocument {
|
||||
onDocumentLoaded( doc );
|
||||
}
|
||||
virtual void onDocumentSyntaxDefinitionChange( const SyntaxDefinition& ) {}
|
||||
virtual void onDocumentMoveHighlight( const Int64& /*fromLine*/,
|
||||
const Int64& /*numLines*/ ){};
|
||||
virtual void onDocumentLineMove( const Int64& /*fromLine*/, const Int64& /*numLines*/ ){};
|
||||
};
|
||||
|
||||
TextDocument( bool verbose = true );
|
||||
@@ -634,7 +633,7 @@ class EE_API TextDocument {
|
||||
|
||||
void notifySyntaxDefinitionChange();
|
||||
|
||||
void notifiyDocumentMoveHighlight( const Int64& fromLine, const Int64& numLines );
|
||||
void notifiyDocumenLineMove( const Int64& fromLine, const Int64& numLines );
|
||||
|
||||
void insertAtStartOfSelectedLines( const String& text, bool skipEmpty );
|
||||
|
||||
|
||||
@@ -463,8 +463,21 @@ class EE_API Window {
|
||||
* per second. */
|
||||
const System::Time& getRenderTimePerSecond() const;
|
||||
|
||||
/** @return The last windowed size of the window */
|
||||
const Sizei& getLastWindowedSize() const;
|
||||
|
||||
/** @return True if implements native message boxes */
|
||||
virtual bool hasNativeMessageBox() const { return false; };
|
||||
|
||||
/** Native message box types */
|
||||
enum class MessageBoxType { Error, Warning, Information };
|
||||
|
||||
/** Shows a native message box.
|
||||
* @return True if message box was shown
|
||||
*/
|
||||
virtual bool showMessageBox( const MessageBoxType& type, const std::string& title,
|
||||
const std::string& message );
|
||||
|
||||
protected:
|
||||
friend class Engine;
|
||||
friend class Input;
|
||||
|
||||
@@ -917,7 +917,7 @@ TextPosition TextDocument::insert( const size_t& cursorIdx, TextPosition positio
|
||||
|
||||
if ( linesAdd > 0 ) {
|
||||
mHighlighter->moveHighlight( position.line(), linesAdd );
|
||||
notifiyDocumentMoveHighlight( position.line(), linesAdd );
|
||||
notifiyDocumenLineMove( position.line(), linesAdd );
|
||||
}
|
||||
|
||||
notifyTextChanged( { { position, position }, text } );
|
||||
@@ -1062,7 +1062,7 @@ size_t TextDocument::remove( const size_t& cursorIdx, TextRange range,
|
||||
|
||||
if ( linesRemoved > 0 ) {
|
||||
mHighlighter->moveHighlight( range.start().line(), -linesRemoved );
|
||||
notifiyDocumentMoveHighlight( range.start().line(), -linesRemoved );
|
||||
notifiyDocumenLineMove( range.start().line(), -linesRemoved );
|
||||
}
|
||||
|
||||
notifyTextChanged( { originalRange, "" } );
|
||||
@@ -2598,10 +2598,10 @@ void TextDocument::notifySyntaxDefinitionChange() {
|
||||
}
|
||||
}
|
||||
|
||||
void TextDocument::notifiyDocumentMoveHighlight( const Int64& fromLine, const Int64& numLines ) {
|
||||
void TextDocument::notifiyDocumenLineMove( const Int64& fromLine, const Int64& numLines ) {
|
||||
Lock l( mClientsMutex );
|
||||
for ( auto& client : mClients ) {
|
||||
client->onDocumentMoveHighlight( fromLine, numLines );
|
||||
client->onDocumentLineMove( fromLine, numLines );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -828,6 +828,28 @@ Float WindowSDL::getScale() {
|
||||
return (Float)realX / (Float)scaledX;
|
||||
}
|
||||
|
||||
bool WindowSDL::hasNativeMessageBox() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
Uint32 toSDLMsgBoxType( const Window::MessageBoxType& type ) {
|
||||
switch ( type ) {
|
||||
case Window::MessageBoxType::Error:
|
||||
return SDL_MESSAGEBOX_ERROR;
|
||||
case Window::MessageBoxType::Warning:
|
||||
return SDL_MESSAGEBOX_WARNING;
|
||||
case Window::MessageBoxType::Information:
|
||||
return SDL_MESSAGEBOX_INFORMATION;
|
||||
}
|
||||
return SDL_MESSAGEBOX_INFORMATION;
|
||||
}
|
||||
|
||||
bool WindowSDL::showMessageBox( const MessageBoxType& type, const std::string& title,
|
||||
const std::string& message ) {
|
||||
return 0 == SDL_ShowSimpleMessageBox( toSDLMsgBoxType( type ), title.c_str(), message.c_str(),
|
||||
mSDLWindow );
|
||||
}
|
||||
|
||||
SDL_Window* WindowSDL::GetSDLWindow() const {
|
||||
return mSDLWindow;
|
||||
}
|
||||
|
||||
@@ -79,6 +79,11 @@ class EE_API WindowSDL : public Window {
|
||||
|
||||
virtual Float getScale();
|
||||
|
||||
virtual bool hasNativeMessageBox() const;
|
||||
|
||||
virtual bool showMessageBox( const MessageBoxType& type, const std::string& title,
|
||||
const std::string& message );
|
||||
|
||||
SDL_Window* GetSDLWindow() const;
|
||||
|
||||
void startTextInput();
|
||||
|
||||
@@ -341,6 +341,10 @@ const Sizei& Window::getLastWindowedSize() const {
|
||||
return mLastWindowedSize;
|
||||
}
|
||||
|
||||
bool Window::showMessageBox( const MessageBoxType&, const std::string&, const std::string& ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void Window::calculateFps() {
|
||||
if ( mFrameData.FPS.LastCheck.getElapsedTime().asSeconds() >= 1.f ) {
|
||||
mFrameData.FPS.Current = mFrameData.FPS.Count;
|
||||
|
||||
@@ -2929,6 +2929,19 @@ void App::init( const LogLevel& logLevel, std::string file, const Float& pidelDe
|
||||
ecode::Version::getCodename().c_str() );
|
||||
|
||||
if ( mWindow->isOpen() ) {
|
||||
// Only verify GPU driver availability on Windows.
|
||||
// macOS will have at least a fallback renderer
|
||||
// Linux will have at least Mesa drivers with LLVM Pipe
|
||||
#if EE_PLATFORM == EE_PLATFORM_WIN
|
||||
if ( !GLi->shadersSupported() ) {
|
||||
mWindow->showMessageBox(
|
||||
EE::Window::Window::MessageBoxType::Error, "ecode",
|
||||
"ecode detected that there are no GPU drivers available or that the GPU does not "
|
||||
"support shaders.\nThis will prevent ecode to properly function.\nPlease check "
|
||||
"that your GPU drivers are installed." );
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
#if EE_PLATFORM == EE_PLATFORM_MACOSX
|
||||
macOS_CreateApplicationMenus();
|
||||
#endif
|
||||
|
||||
@@ -233,7 +233,7 @@ void LSPDocumentClient::processTokens( const LSPSemanticTokensDelta& tokens ) {
|
||||
mRunningSemanticTokens = false;
|
||||
}
|
||||
|
||||
void LSPDocumentClient::onDocumentMoveHighlight( const Int64& fromLine, const Int64& numLines ) {
|
||||
void LSPDocumentClient::onDocumentLineMove( const Int64& fromLine, const Int64& numLines ) {
|
||||
Int64 linesCount = mDoc->linesCount();
|
||||
if ( numLines > 0 ) {
|
||||
for ( Int64 i = linesCount - 1; i >= fromLine; --i ) {
|
||||
|
||||
@@ -37,7 +37,7 @@ class LSPDocumentClient : public TextDocument::Client {
|
||||
virtual void onDocumentDirtyOnFileSystem( TextDocument* );
|
||||
virtual void onDocumentMoved( TextDocument* );
|
||||
virtual void onDocumentReloaded( TextDocument* );
|
||||
virtual void onDocumentMoveHighlight( const Int64& fromLine, const Int64& numLines );
|
||||
virtual void onDocumentLineMove( const Int64& fromLine, const Int64& numLines );
|
||||
|
||||
void notifyOpen();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user